This module provides a random number generator. The module contains
a number of algorithms. The uniform distribution algorithms use the
For some algorithms, jump functions are provided for generating non-overlapping sequences for parallel computations. The jump functions perform calculations equivalent to perform a large number of repeated calls for calculating new states.
The following algorithms are provided:
Xorshift116+, 58 bits precision and period of 2^116-1
Jump function: equivalent to 2^64 calls
Xorshift64*, 64 bits precision and a period of 2^64-1
Jump function: not available
Xorshift1024*, 64 bits precision and a period of 2^1024-1
Jump function: equivalent to 2^512 calls
The default algorithm is
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 or be an explicit argument and return value.
The functions with implicit state use the process dictionary
variable
If a process calls
The functions with explicit state never use the process dictionary.
Examples:
Simple use; creates and seeds the default algorithm with a non-constant seed if not already done:
R0 = rand:uniform(), R1 = rand:uniform(),
Use a specified algorithm:
_ = rand:seed(exs1024), R2 = rand:uniform(),
Use a specified algorithm with a constant seed:
_ = rand:seed(exs1024, {123, 123534, 345345}), R3 = rand:uniform(),
Use the functional API with a non-constant seed:
S0 = rand:seed_s(exsplus), {R4, S1} = rand:uniform_s(S0),
Create a standard normal deviate:
{SND0, S2} = rand:normal_s(S1),
The builtin random number generator algorithms are not
cryptographically strong. If a cryptographically strong
random number generator is needed, use something like
Algorithm specific internal state
Algorithm specific internal state
Algorithm specific internal state
Algorithm-dependent state.
Algorithm-dependent state that can be printed or saved to file.
Returns the random number state in an external format.
To be used with
Returns the random number generator state in an external format.
To be used with
Returns the state after performing jump calculation to the state in the process dictionary.
This function generates a
Returns the state after performing jump calculation to the given state.
This function generates a
Returns a standard normal deviate float (that is, the mean is 0 and the standard deviation is 1) and updates the state in the process dictionary.
Returns, for a specified state, a standard normal deviate float (that is, the mean is 0 and the standard deviation is 1) and a new state.
Seeds random number generation with the specifed algorithm and
time-dependent data if
Otherwise recreates the exported seed in the process dictionary,
and returns the state. See also
Seeds random number generation with the specified algorithm and integers in the process dictionary and returns the state.
Seeds random number generation with the specifed algorithm and
time-dependent data if
Otherwise recreates the exported seed and returns the state.
See also
Seeds random number generation with the specified algorithm and integers and returns the state.
Returns a random float uniformly distributed in the value
range
Returns, for a specified integer
Returns, for a specified state, random float
uniformly distributed in the value range
Returns, for a specified integer