Random number generator.
The module contains several different algorithms and can be
extended with more in the future. The current uniform
distribution algorithms uses the
The implemented algorithms are:
The current default algorithm is
Every time a random number is requested, a state is used to calculate it and a new state produced. The state can either be implicit or it can 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 usage. Creates and seeds the default algorithm %% with a non-constant seed if not already done. R0 = rand:uniform(), R1 = rand:uniform(), %% Use a given algorithm. _ = rand:seed(exs1024), R2 = rand:uniform(), %% Use a given algorithm with a constant seed. _ = rand:seed(exs1024, {123, 123534, 345345}), R3 = rand:uniform(), %% Use the functional api with 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),
This random number generator is not cryptographically
strong. If a strong cryptographic random number generator is
needed, use one of functions in the
Algorithm dependent state.
Algorithm dependent state which can be printed or saved to file.
Seeds random number generation with the given 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 given algorithm and time dependent
data if
Otherwise recreates the exported seed and returns the state.
See also:
Seeds random number generation with the given algorithm and integers in the process dictionary and returns the state.
Seeds random number generation with the given algorithm and integers and returns the state.
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 a random float uniformly distributed in the value
range
Given a state,
Given an integer
Given an integer
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.
Given a state,