Callable objects that generate numbers according to different distributions.
Bases: numbergen.RandomDistribution
Normally distributed (Gaussian) random number.
Specified with mean mu and standard deviation sigma. See the random module for further details.
Bases: numbergen.NumberGenerator
Applies any binary operator to NumberGenerators or numbers to yield a NumberGenerator.
Bases: numbergen.RandomDistribution
Specified with lbound and ubound; when called, return a random number in the range [lbound, ubound).
See the random module for further details.
Bases: numbergen.NumberGenerator, numbergen.TimeDependent
The boxcar function over the specified time interval. The bounds are exclusive: zero is returned at the onset time and at the offset (onset+duration).
If duration is None, then this reduces to a step function around the onset value with no offset.
See http://en.wikipedia.org/wiki/Boxcar_function
Bases: numbergen.NumberGenerator, numbergen.TimeDependent
Generate a square wave with ‘on’ periods returning 1.0 and ‘off’periods returning 0.0 of specified duration(s). By default the portion of time spent in the high state matches the time spent in the low state (a duty cycle of 50%), but the duty cycle can be controlled if desired.
The ‘on’ state begins after a time specified by the ‘onset’ parameter. The onset duration supplied must be less than the off duration.
Bases: numbergen.NumberGenerator, numbergen.TimeDependent
The current time multiplied by some conversion factor.
Bases: numbergen.RandomDistribution
Circularly normal distributed random number.
If kappa is zero, this distribution reduces to a uniform random angle over the range 0 to 2*pi. Otherwise, it is concentrated to a greater or lesser degree (determined by kappa) around the mean mu. For large kappa (narrow peaks), this distribution approaches the Gaussian (normal) distribution with variance 1/kappa. See the random module for further details.
Bases: numbergen.RandomDistribution
Return a random element from the specified list of choices.
Accepts items of any type, though they are typically numbers. See the choice() function in the random module for further details.
Bases: numbergen.RandomDistribution
Specified with lbound and ubound; when called, return a random number in the inclusive range [lbound, ubound].
See the randint function in the random module for further details.
Bases: numbergen.NumberGenerator
Function object that silently enforces numeric bounds on values returned by a callable object.
Bases: numbergen.NumberGenerator, numbergen.TimeDependent
Function object that provides a value that decays according to an exponential function, based on a given time function.
Returns starting_value*base^(-time/time_constant).
See http://en.wikipedia.org/wiki/Exponential_decay.
Bases: numbergen.NumberGenerator
Applies any unary operator to a NumberGenerator to yield another NumberGenerator.
Bases: numbergen.NumberGenerator, numbergen.TimeAware
Python’s random module provides the Random class, which can be instantiated to give an object that can be asked to generate numbers from any of several different random distributions (e.g. uniform, Gaussian).
To make it easier to use these, Numbergen provides here a hierarchy of classes, each tied to a particular random distribution. RandomDistributions support setting parameters on creation rather than passing them each call, and allow pickling to work properly. Code that uses these classes will be independent of how many parameters are used by the underlying distribution, and can simply treat them as a generic source of random numbers.
The underlying random.Random() instance and all its methods can be accessed from the ‘random_generator’ attribute.
RandomDistributions are TimeAware, and thus can be locked to a global time if desired. By default, time_dependent=False, and so a new random value will be generated each time these objects are called. If you have a global time function, you can set time_dependent=True, so that the random values will instead be constant at any given time, changing only when the time changes. Using time_dependent values can help you obtain fully reproducible streams of random numbers, even if you e.g. move time forwards and backwards for testing.
If declared time_dependent, a hash is generated for seeding the random state on each call, using a triple consisting of the object name, the time returned by time_fn and the global value of param.random_seed. As a consequence, for a given name and fixed value of param.random_seed, the random values generated will be a fixed function of time.
If the object name has not been set and time_dependent is True, a message is generated warning that the default object name is dependent on the order of instantiation. To ensure that the random number stream will remain constant even if other objects are added or reordered in your file, supply a unique name explicitly when you construct the RandomDistribution object.
Bases: numbergen.NumberGenerator, numbergen.TimeDependent
Samples the values supplied by a time_dependent callable at regular intervals of duration ‘period’, with the sampled value held constant within each interval.
Bases: param.parameterized.Parameterized
Abstract base class for any object that when called produces a number.
Primarily provides support for using NumberGenerators in simple arithmetic expressions, such as abs((x+y)/z), where x,y,z are NumberGenerators or numbers.
Bases: numbergen.RandomDistribution
Identical to UniformRandom, but specified by mean and range. When called, return a random number in the range [mean - range/2, mean + range/2).
See the random module for further details.