Random Number Generator¶
Module to offer ‘really deterministic’ (pseudo-)random number generation in a Distributed Time Warp implementation.
For local simulation, using the random library from Python as usual is perfectly ok.
- class pypdevs.randomGenerator.RandomGenerator(seed)[source]
Base class, which implements a random number interface for the ‘uniform’ and ‘random’ Python standard library functions.
Note
The generated random numbers are not equal to those generated by direct calls to the library functions, as we also use a random number to initialize the seed in the next iteration.
- __init__(seed)[source]
Constructor
- Parameters
seed – the seed to start with, this will simply be passed to the random library at every function call
- copy()[source]
A copy method to be used when defining custom state saving methods. It will return a complete copy of this random number generator, which will generate exactly the same sequence of numbers.
- random()[source]
Call the random function of the random library.
- Returns
float – a random value between 0 and 1
- uniform(a, b)[source]
Call the uniform function of the random library.
- Parameters
a – lower bound of generated value
b – upper bound of generated value
- Returns
float – the generated value