def __init__(self, alpha=0.1, beta=0.1): Function.__init__(self) self.uniformRNG = UniformRNG() self.betavariateRNG = _BetavariateRNG() self.alpha = make_function(alpha) self.beta = make_function(beta)
def __init__(self, pairs, periodic=0): """ Return a BPF instance. pair is the list of pairs (time, value). At lease the pairs should be passed, otherwise a ValueError exception is raised. if periodic is true the periodic version of the call operator is used. if periodic is false the aperiodic version of the call operator is used. >>> a = BPF([(0,1), (100, 20)]) """ Function.__init__(self) self.pairs = [(float(x), float(y)) for x, y in pairs] self._check_pairs() if len(self.pairs) < 2: raise ValueError('Two few pairs (%d)' % len(self.pairs)) self.xStart, junk = self.pairs[0] # x value of first self.xEnd, junk = self.pairs[-1] # x value of last self.period = self.xEnd - self.xStart self._is_periodic = periodic
def __init__(self, alpha = 0.1, beta = 0.1): Function.__init__(self) self.uniformRNG = UniformRNG() self.betavariateRNG = _BetavariateRNG() self.alpha = make_function(alpha) self.beta = make_function(beta)
def __init__(self, pairs, periodic=0): """ Return a BPF instance. pair is the list of pairs (time, value). At lease the pairs should be passed, otherwise a ValueError exception is raised. if periodic is true the periodic version of the call operator is used. if periodic is false the aperiodic version of the call operator is used. >>> a = BPF([(0,1), (100, 20)]) """ Function.__init__(self) self.pairs = [(float(x), float(y)) for x,y in pairs] self._check_pairs() if len(self.pairs) < 2: raise ValueError('Two few pairs (%d)' % len(self.pairs)) self.xStart, junk = self.pairs[0] # x value of first self.xEnd, junk = self.pairs[-1] # x value of last self.period = self.xEnd - self.xStart if periodic: self.__call__ = self._evaluate_periodic else: self.__call__ = self._evaluate_aperiodic
def __init__(self, pair0, *pairs): Function.__init__(self) for pair in pairs: if type(pair) is not types.TupleType: raise ValueError, 'pair (object, probability) expected. got %s', repr(pair) self.set = [] for o, p in [pair0] + list(pairs): self.set.append(_PossibleChoice(o, make_function(p)))
def __init__(self, pair0, *pairs): Function.__init__(self) for pair in pairs: if type(pair) is not types.TupleType: raise ValueError, "pair (object, probability) expected. got %s", repr(pair) self.set = [] for o, p in [pair0] + list(pairs): self.set.append(_PossibleChoice(o, make_function(p)))
def __init__(self, pair, *pairs): Function.__init__(self) pairs = [pair] + list(pairs) self.set = [] for o, p in pairs: self.set.append(_PossibleChoice(o, p)) sum = reduce(lambda x, y: x + y, [possible_choice.probability for possible_choice in self.set]) self.set = map(_MarkAccumulator(sum), self.set)
def __init__(self, pair, *pairs): Function.__init__(self) pairs = [pair] + list(pairs) self.set = [] for o, p in pairs: self.set.append(_PossibleChoice(o, p)) sum = reduce(lambda x,y: x+y, [possible_choice.probability for possible_choice in self.set]) self.set = map(_MarkAccumulator(sum), self.set)
def __init__(self, value_generator, mode='unbound', lower=None, upper=None, sum0=0): """ Return an Accumulator instance. If mode is 'unbound' (default value) the accumulation is not limited. If mode is 'reflect' or 'r' or 'mirror' or 'm', the Accumulator folds values inside the [lower, upper] range. lower and upper must be specified and may be functions. If mode 'wrap' or 'w', the Accumulator performs a wrap around at the lower and upper limits. lower and upper must be specified and may be functions. An Accumulator can be initialized by passing the sum0 argument. """ Function.__init__(self) self.generator = make_function(value_generator) self.sum = sum0 if mode in ['unbound', 'u']: self.add = self.noBounds else: if upper is None or lower is None: raise ValueError( 'cannot create a bound accumulator with undefined bounds') self.upper = make_function(upper) self.lower = make_function(lower) if mode in ['limit', 'l']: self.add = self.limitAtBounds elif mode in ['reflect', 'r', 'mirror', 'm']: self.add = self.reflectAtBounds elif mode in ['wrap', 'w']: self.add = self.wrapAtBounds else: raise ValueError( "mode can only be 'unbound', 'limit', 'reflect', 'mirror' or 'wrap' (got %s)" % mode)
def __init__(self, value_generator, mode="unbound", lower=None, upper=None, sum0=0): """ Return an Accumulator instance. If mode is 'unbound' (default value) the accumulation is not limited. If mode is 'reflect' or 'r' or 'mirror' or 'm', the Accumulator folds values inside the [lower, upper] range. lower and upper must be specified and may be functions. If mode 'wrap' or 'w', the Accumulator performs a wrap around at the lower and upper limits. lower and upper must be specified and may be functions. An Accumulator can be initialized by passing the sum0 argument. """ Function.__init__(self) self.generator = make_function(value_generator) self.sum = sum0 if mode in ["unbound", "u"]: self.add = self.noBounds else: if upper is None or lower is None: raise ValueError, "cannot create a bound accumulator with undefined bounds" self.upper = make_function(upper) self.lower = make_function(lower) if mode in ["limit", "l"]: self.add = self.limitAtBounds elif mode in ["reflect", "r", "mirror", "m"]: self.add = self.reflectAtBounds elif mode in ["wrap", "w"]: self.add = self.wrapAtBounds else: raise ValueError, "mode can only be 'unbound', 'limit', 'reflect', 'mirror' or 'wrap' (got %s)" % mode
def __init__(self, mainFunction, lowerLimit, upperLimit, exp=0.0): Function.__init__(self) self.upperLimit = make_function(upperLimit) self.lowerLimit = make_function(lowerLimit) self.mainFunction = make_function(mainFunction) self.exponent = math.pow(2.0, exp)
def __init__(self, generator, points, strength=1.0, exponent=0.0): Function.__init__(self) self.generator = make_function(generator) self.points = make_function(points) self.strength = make_function(strength) self.exponent = make_function(exponent)
def __init__(self, generator, delta, strength=1.0, offset=0.0): Function.__init__(self) self.generator = make_function(generator) self.delta = make_function(delta) self.strength = make_function(strength) self.offset = make_function(offset)
def __init__(self, frequency=1.0, phase0=0.0): Function.__init__(self) self.frequency = frequency self.phase0 = phase0
def __init__(self, lambd=1.0): Function.__init__(self) self.lambd = make_function(lambd) self.expovariateRNG = _ExpovariateRNG() self.uniformRNG = UniformRNG()
def __init__(self, mainFunction, lowerLimit, upperLimit, exp = 0.0): Function.__init__(self) self.upperLimit = make_function(upperLimit) self.lowerLimit = make_function(lowerLimit) self.mainFunction = make_function(mainFunction) self.exponent = math.pow(2.0, exp)
def __init__(self, generator, points, strength = 1.0, exponent = 0.0): Function.__init__(self) self.generator = make_function(generator) self.points = make_function(points) self.strength = make_function(strength) self.exponent = make_function(exponent)
def __init__(self, generator, delta, strength = 1.0, offset = 0.0): Function.__init__(self) self.generator = make_function(generator) self.delta = make_function(delta) self.strength = make_function(strength) self.offset = make_function(offset)
def __init__(self, frequency=1.0, phase0=0.0): Function.__init__(self) self.frequency = frequency # this is time per period self.T = None # require when called self.phase0 = phase0
def __init__(self, mu = 0.5, sigma = 0.1): Function.__init__(self) self.mu = make_function(mu) self.sigma = make_function(sigma) self.gaussRNG = _GaussRNG()
def __init__(self, alpha=0.1, mu=0.5): Function.__init__(self) self.alpha = make_function(alpha) self.mu = make_function(mu) self.uniformRNG = UniformRNG()
def __init__(self, mu=0.5, sigma=0.1): Function.__init__(self) self.mu = make_function(mu) self.sigma = make_function(sigma) self.gaussRNG = _GaussRNG()
def __init__(self, frequency=1.0, phase0=0.0): Function.__init__(self) self.frequency = frequency self.phase0 = phase0 self.T = None # require when called
def __init__(self, lambd = 1.0): Function.__init__(self) self.lambd = make_function(lambd) self.expovariateRNG = _ExpovariateRNG() self.uniformRNG = UniformRNG()
def __init__(self, alpha = 0.1, mu = 0.5): Function.__init__(self) self.alpha = make_function(alpha) self.mu = make_function(mu) self.uniformRNG = UniformRNG()