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.
- __eq__(other)[source]¶
Compare two instances of random number generators.
Needed for memoization.
- Parameters
other – the instance to compare with
- Returns
bool – do these random number generators return the same sequence?
- __hash__()[source]¶
Hash this random number generator.
Needed as the comparison method was changed!
- Returns
hash
- __init__(seed)[source]¶
Constructor
- Parameters
seed – the seed to start with, this will simply be passed to the random library at every function call
- __weakref__¶
list of weak references to the object (if defined)
- 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.