random

Random variable generators.

uniform within range
pick random element pick random sample generate random permutation
uniform triangular normal (Gaussian) lognormal negative exponential gamma beta pareto Weibull
circular uniform von Mises

General notes on the underlying Mersenne Twister core generator:

  • The period is 2**19937-1.
  • It is one of the most extensively tested generators in existence.
  • Without a direct way to compute N steps forward, the semantics of jumpahead(n) are weakened to simply jump to another distant state and rely on the large period to avoid overlapping sequences.
  • The random() method is implemented in C, executes in a single Python step, and is, therefore, threadsafe.

Functions

getrandbits(...)
random(() -> x in the interval [0, 1).)

Classes

Random([x]) Random number generator base class used by bound module functions.
SystemRandom([x]) Alternate random number generator using sources provided by the operating system (such as /dev/urandom on Unix or CryptGenRandom on Windows).
WichmannHill([x])