Welcome to mrg32k3a’s documentation!

This package provides a Python implementation of the mrg32k3a pseudo-random number generator of L’Ecuyer (1999) and L’Ecuyer et al. (2002). It extends the implementation used in PyMOSO to handle streams, substreams, and subsubstreams. The generator’s period of \(~2^{191}\) is split into \(~2^{50}\) streams of length \(2^{141}\), each containing \(2^{47}\) substreams of length \(2^{94}\), each containing \(2^{47}\) subsubstreams of length \(2^{47}\).

Details

The mrg32k3a module includes the MRG32k3a class and several useful functions for controlling the generators.

  • The MRG32k3a class is a subclass of Python’s random.Random class and therefore inherits easy-to-use methods for generating random variates. E.g., if rng is an instance of the MRG32k3a class, the command rng.normalvariate(mu=2, sigma=5) generates a normal random variate with mean 2 and standard deviation 5. Normal random variates are generated via inversion using the Beasley-Springer-Moro algorithm.

  • The MRG32k3a class expands the suite of functions for random-variate generation available in random.Random to include lognormalvariate, mvnormalvariate, poissonvariate, gumbelvariate, binomialvariate. Additionally, the methods integer_random_vector_from_simplex and continuous_random_vector_from_simplex generate discrete and continuous vectors from a symmetric non-negative simplex.

  • The advance_stream, advance_substream, and advance_subsubstream functions advance the generator to the start of the next stream, substream, or subsubstream, respectively. They make use of techniques for efficiently “jumping ahead,” as outlined by L’Ecuyer (1990).

  • The reset_stream, reset_substream, and reset_subsubstream functions reset the generator to the start of the current stream, substream, or subsubstream, respectively.

The matmodops module includes basic matrix/modulus operations used by the mrg32k3a module.

Documentation

Full documentation for the mrg32k3a and matmodops modules.

References