def __init__(self, other_param, minval=None, maxval=None): StochasticParameter.__init__(self) assert isinstance(other_param, StochasticParameter) assert minval is None or ia.is_single_number(minval) assert maxval is None or ia.is_single_number(maxval) self.other_param = other_param self.minval = minval self.maxval = maxval
def __init__(self, value): StochasticParameter.__init__(self) if isinstance(value, StochasticParameter): self.value = value.draw_sample() elif ia.is_single_number(value) or ia.is_string(value): self.value = value else: raise Exception( "Expected StochasticParameter object or number or string, got %s." % (type(value), ))
def __init__(self, a, b): StochasticParameter.__init__(self) assert isinstance( a, (int, float, StochasticParameter) ), "Expected a to be int, float or StochasticParameter, got %s" % ( type(a), ) assert isinstance( b, (int, float, StochasticParameter) ), "Expected b to be int, float or StochasticParameter, got %s" % ( type(b), ) if ia.is_single_number(a): self.a = Deterministic(a) else: self.a = a if ia.is_single_number(b): self.b = Deterministic(b) else: self.b = b
def __init__(self, p): StochasticParameter.__init__(self) if isinstance(p, StochasticParameter): self.p = p elif ia.is_single_number(p): assert 0 <= p <= 1.0, "Expected probability p to be in range [0.0, 1.0], got %s." % ( p, ) self.p = Deterministic(float(p)) else: raise Exception( "Expected StochasticParameter or float/int value, got %s." % (type(p), ))
def __init__(self, loc, scale): StochasticParameter.__init__(self) if isinstance(loc, StochasticParameter): self.loc = loc elif ia.is_single_number(loc): self.loc = Deterministic(loc) else: raise Exception( "Expected float, int or StochasticParameter as loc, got %s, %s." % (type(loc), )) if isinstance(scale, StochasticParameter): self.scale = scale elif ia.is_single_number(scale): assert scale >= 0, "Expected scale to be in range [0, inf) got %s (type %s)." % ( scale, type(scale)) self.scale = Deterministic(scale) else: raise Exception( "Expected float, int or StochasticParameter as scale, got %s, %s." % (type(scale), ))