# 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)

  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)

    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__()

    Hash this random number generator.

    Needed as the comparison method was changed!

    Returns

      hash

  __init__(seed)

    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()

    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()

    Call the random function of the random library.

    Returns

      float – a random value between 0 and 1

  uniform(a, b)

    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