Example #1
0
 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)
Example #2
0
    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)
Example #3
0
    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)
Example #4
0
    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)))
Example #5
0
     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)))
Example #6
0
    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
Example #7
0
    def __init__(self, alpha=0.5, beta=2.0):
        Generator.__init__(self)
        self.alpha = make_function(alpha)
        self.beta = make_function(beta)

        self.weibullvariateRNG = _WeibullvariateRNG()
Example #8
0
 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)
Example #9
0
 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)
Example #10
0
 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)
Example #11
0
 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)
Example #12
0
 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)
Example #13
0
 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)
Example #14
0
 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()
Example #15
0
 def __init__(self, lambd = 1.0):
      Function.__init__(self)
      self.lambd = make_function(lambd)
      self.expovariateRNG = _ExpovariateRNG()
      self.uniformRNG = UniformRNG()
Example #16
0
 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()
Example #17
0
 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()
Example #18
0
 def __init__(self, lambd=1.0):
     Function.__init__(self)
     self.lambd = make_function(lambd)
     self.expovariateRNG = _ExpovariateRNG()
     self.uniformRNG = UniformRNG()
Example #19
0
     def __init__(self, alpha = 0.5, beta = 2.0):
          Generator.__init__(self)
          self.alpha = make_function(alpha)
          self.beta = make_function(beta)

          self.weibullvariateRNG = _WeibullvariateRNG()
Example #20
0
 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()