Module random - Random number generation
Random number generation.
Index
-
Record
RANDOM.STATE- The internal state of the random number generator -
Function
random.bool- Generate a random BOOL -
Function
random.gaussian.real32- Generate a random REAL32 from a Gaussian distribution -
Function
random.gaussian.real32s- Generate two random REAL32 s from a Gaussian distribution -
Function
random.get- Generate 32 bits of random data -
Function
random.init- Initialise RNG state given (up to) 32 bits of initial entropy -
Process
random.init.from.time- Initialise an RNG using the current time as initial entropy -
Function
random.int- Generate a random INT -
Function
random.real32- Generate a random REAL32 -
Function
random.real32.signed- Generate a random signed REAL32 -
Function
random.split- Given an RNG state, compute two new states deterministically from it that have a low probability of generating overlapping sequences
Declarations
random.occ:30Function random.init
RANDOM.STATE FUNCTION random.init (VAL INT32 seed)
Initialise RNG state given (up to) 32 bits of initial entropy.
random.occ:36Function random.get
INT32, RANDOM.STATE FUNCTION random.get (VAL RANDOM.STATE state)
Generate 32 bits of random data. Returns the data and a new RNG state.
random.occ:64Process random.init.from.time
PROC random.init.from.time (RESULT RANDOM.STATE state)
Initialise an RNG using the current time as initial entropy.
random.occ:75Function random.split
RANDOM.STATE, RANDOM.STATE FUNCTION random.split (VAL RANDOM.STATE state)
Given an RNG state, compute two new states deterministically from it that have a low probability of generating overlapping sequences.
random.occ:94Function random.int
INT, RANDOM.STATE FUNCTION random.int (VAL INT max, VAL RANDOM.STATE state)
Generate a random INT.
Parameters:
VAL INT |
max |
Upper limit |
VAL RANDOM.STATE |
state |
Current RNG state |
Returns:
INT |
Output value, uniformly distributed in the range [0, max). |
|
RANDOM.STATE |
New RNG state |
random.occ:112Function random.real32
REAL32, RANDOM.STATE FUNCTION random.real32 (VAL REAL32 max, VAL RANDOM.STATE state)
Generate a random REAL32.
Parameters:
VAL REAL32 |
max |
Upper limit |
VAL RANDOM.STATE |
state |
Current RNG state |
Returns:
REAL32 |
Output value, uniformly distributed in the range [0, max). |
|
RANDOM.STATE |
New RNG state |
random.occ:131Function random.real32.signed
REAL32, RANDOM.STATE FUNCTION random.real32.signed (VAL REAL32 max, VAL RANDOM.STATE state)
Generate a random signed REAL32.
Parameters:
VAL REAL32 |
max |
Upper limit |
VAL RANDOM.STATE |
state |
Current RNG state |
Returns:
REAL32 |
Output value, uniformly distributed in the range [[@code -max], max). |
|
RANDOM.STATE |
New RNG state |
random.occ:151Function random.gaussian.real32s
REAL32, REAL32, RANDOM.STATE FUNCTION random.gaussian.real32s (VAL RANDOM.STATE state)
Generate two random REAL32s from a Gaussian distribution.
This function exists because the Box-Muller transform used to generate Gaussian-distributed numbers in this module produces two results at a time.
Parameters:
VAL RANDOM.STATE |
state |
Current RNG state |
Returns:
REAL32 |
value1, value2
|
Two output values from a Gaussian distribution with mean 0.0 and standard deviation 1.0 |
RANDOM.STATE |
new.state |
New RNG state |
random.occ:189Function random.gaussian.real32
REAL32, RANDOM.STATE FUNCTION random.gaussian.real32 (VAL RANDOM.STATE state)
Generate a random REAL32 from a Gaussian distribution.
Parameters:
VAL RANDOM.STATE |
state |
Current RNG state |
Returns:
REAL32 |
value |
Output value from a Gaussian distribution with mean 0.0 and standard deviation 1.0 |
RANDOM.STATE |
new.state |
New RNG state |
random.occ:207Function random.bool
BOOL, RANDOM.STATE FUNCTION random.bool (VAL REAL32 prob, VAL RANDOM.STATE state)
Generate a random BOOL.
Parameters:
VAL REAL32 |
prob |
Probability that the result will be TRUE
|
VAL RANDOM.STATE |
state |
Current RNG state |
Returns:
BOOL |
Output value | |
RANDOM.STATE |
New RNG state |
random.inc:25Record RANDOM.STATE
DATA TYPE RANDOM.STATE
The internal state of the random number generator.