Alea::XSR128
Inherits Alea::XSR / Alea::PRNG / Reference / Object
Alea::XSR128 is the default pseudo-random number generator, with a state of 128 bits, and therefore
a period of 2^64 -1. It is as fast as Random::PCG32, but yielding a 64-bit unsigned integer.
If more state is needed, check Alea::XSR256.
- period: 2^128 -1
- state type: UInt64
Constants
Constructors
Initializes the PRNG with initial seeds.
@parameters:
seed32: value as input to init. the state of 32-bit generators.seed64: value as input to init. the state of 64-bit generators.
@references:
Alea::Core::Mulberry32(4)#init_state.Alea::Core::SplitMix64(2)#init_state.
@exceptions:
Alea::UndefinedErrorif any ofseed32orseed64is negative.
Initializes the PRNG with initial states.
@parameters:
state32: array of values for state of 32-bit generators.state64: array of values for state of 64-bit generators.
Initializes the PRNG with initial seed.
@parameters:
seed: value as input to init. the state of both 32-bit and 64-bit generators.
@references:
Alea::Core::Mulberry32(4)#init_state.Alea::Core::SplitMix64(2)#init_state.
@exceptions:
Alea::UndefinedErrorifseedis negative.
Instance methods
Performs an advance over the 32-bit state.
This is the equivalent of 2^64 calls to #next_u32.
@parameters:
long: flag to advance the state by2^96calls.
Performs an advance over the 64-bit state.
This is the equivalent of 2^64 calls to #next_u64.
@parameters:
long: flag to advance the state by2^96calls.
Generate a uniform-distributed random UInt32.
@examples:
rng = Alea::XSR128.new
rng.next_u32 # => 1767702788
Generate a uniform-distributed random UInt64.
@examples:
rng = Alea::XSR128.new
rng.next_u64 # => 9136120204379184874