# Pseudorandom number generator¶

This module implements the Mersenne Twister algorithm for pseudo-random number generation. It is based on now-defunct projects by Makoto Matsumoto and Takuji Nishimura and Jasper Bedaux for the core generator, and on Egglib version 2 for conversion to other laws than uniform. All non-uniform distribution laws generators are based either on the random.integer_32bit() or the standard (half-open, 32 bit) random.uniform() methods.

Note that the pseudo-random number generator is seeded, by default, using the system clock and that it will yield the exact same sequence of random numbers (regardless of the distribution law used) if the seed is identical. This means that different processes started have the same time will be based on the same sequence of random number. It is possible to get and set the seed at any time (see the corresponding methods below).

The content of the module is listed below:

 egglib.random.get_seed Get the seed used to configure the pseudorandom number generator. egglib.random.set_seed Set the seed. egglib.random.uniform Draw a value in the half-open interval $$[0,1)$$ with default 32-bit precision. egglib.random.uniform_53bit Draw a value in the half-open interval $$[0,1)$$ with increased 53-bit precision. egglib.random.uniform_closed Draw a value in the closed interval $$[0,1]$$. egglib.random.uniform_open Draw a value in the open interval $$(0,1)$$. egglib.random.integer Draw an integer from a uniform distribution. egglib.random.integer_32bit Generate a 32-bit random integer (in the range $$[0, 2^{32-1}]$$). egglib.random.boolean Draw a boolean with equal probabilities ($$p = 0.5$$). egglib.random.bernoulli Draw a boolean with given probability. egglib.random.binomial Draw a value from a binomial distribution. egglib.random.exponential Draw a value from an exponential distribution. egglib.random.geometric Draw a value from a geometric distribution. egglib.random.normal Draw a value from the normal distribution.. egglib.random.normal_bounded Draw a value from a bounded normal distribution. egglib.random.poisson Draw a value from a Poisson distribution.
egglib.random.get_seed()

Get the seed used to configure the pseudorandom number generator.

egglib.random.set_seed()

Set the seed.

egglib.random.uniform()

Draw a value in the half-open interval $$[0,1)$$ with default 32-bit precision.

egglib.random.uniform_53bit()

Draw a value in the half-open interval $$[0,1)$$ with increased 53-bit precision.

egglib.random.uniform_closed()

Draw a value in the closed interval $$[0,1]$$.

egglib.random.uniform_open()

Draw a value in the open interval $$(0,1)$$.

egglib.random.integer()

Draw an integer from a uniform distribution.

egglib.random.integer_32bit()

Generate a 32-bit random integer (in the range $$[0, 2^{32-1}]$$).

egglib.random.boolean()

Draw a boolean with equal probabilities ($$p = 0.5$$).

egglib.random.bernoulli()

Draw a boolean with given probability.

egglib.random.binomial()

Draw a value from a binomial distribution.

egglib.random.exponential()

Draw a value from an exponential distribution.

egglib.random.geometric()

Draw a value from a geometric distribution.

egglib.random.normal()

Draw a value from the normal distribution..

egglib.random.normal_bounded()

Draw a value from a bounded normal distribution.

egglib.random.poisson()

Draw a value from a Poisson distribution.