This module provides a random number generator. The method is attributed to B.A. Wichmann and I.D. Hill in 'An efficient and portable pseudo-random number generator', Journal of Applied Statistics. AS183. 1982. Also Byte March 1987.
The algorithm is a modification of the version attributed to Richard A. O'Keefe in the standard Prolog library.
Every time a random number is requested, a state is used to calculate
it, and a new state is produced. The state can either be implicit (kept
in the process dictionary) or be an explicit argument and return value.
In this implementation, the state (the type
This random number generator is not cryptographically
strong. If a strong cryptographic random number generator is
needed, use one of functions in the
The improved
The state.
Seeds random number generation with default (fixed) values in the process dictionary and returns the old state.
Seeds random number generation with integer values in the process dictionary and returns the old state.
The following is an easy way of obtaining a unique value to seed with:
random:seed(erlang:phash2([node()]),
erlang:monotonic_time(),
erlang:unique_integer())
For details, see
Returns the default state.
Returns a random float uniformly distributed between
Returns, for a specified integer
Returns, for a specified state, a random float uniformly
distributed between
Returns, for a specified integer
Some of the functions use the process dictionary variable
If a process calls
The implementation changed in Erlang/OTP R15. Upgrading to R15 breaks
applications that expect a specific output for a specified seed. The
output is still deterministic number series, but different compared to
releases older than R15. Seed