5.3 Standard Module whrandom

This module implements a Wichmann-Hill pseudo-random number generator class that is also named whrandom. Instances of the whrandom class have the following methods:

choice (seq)
Chooses a random element from the non-empty sequence seq and returns it.

randint (a, b)
Returns a random integer N such that a<=N<=b.

random ()
Returns the next random floating point number in the range [0.0 ... 1.0).

seed (x, y, z)
Initializes the random number generator from the integers x, y and z. When the module is first imported, the random number is initialized using values derived from the current time.

uniform (a, b)
Returns a random real number N such that a<=N<b.

When imported, the whrandom module also creates an instance of the whrandom class, and makes the methods of that instance available at the module level. Therefore one can write either N = whrandom.random() or:

generator = whrandom.whrandom()
N = generator.random()

See Also:

Module random   (generators for various random distributions)

Wichmann, B. A. & Hill, I. D., ``Algorithm AS 183: An efficient and portable pseudo-random number generator'', Applied Statistics 31 (1982) 188-190