class Alea::XSR128
- Alea::XSR128
- Reference
- Object
Overview
Alea::XSR128
, pseudo-random number generator loaded with a state of 128 bits
and therefore a period of 2^128 -1. It is as fast as Random::PCG32
.
If more period is needed, check out Alea::XSR256
.
Included Modules
Defined in:
Constant Summary
-
JUMP_32B_64 =
StaticArray[2271477771_u32, 4114797267_u32, 1872770499_u32, 2012404571_u32]
-
JUMP_32B_96 =
StaticArray[3039008046_u32, 191826335_u32, 3438649583_u32, 475530850_u32]
-
JUMP_64B_64 =
StaticArray[3159176899437800924_u64, 689838746718161413_u64]
-
JUMP_64B_96 =
StaticArray[3895567441539718553_u64, 11272061779601802979_u64]
-
STATE_STORAGE_32 =
4
-
STATE_STORAGE_64 =
2
Constructors
-
.new(seed32 : UInt32, seed64 : UInt64)
Initializes the PRNG with initial seeds.
-
.new(seed32 : Int, seed64 : Int)
Initializes the PRNG with initial seeds.
-
.new(seed : Int)
Initializes the PRNG with initial seed.
-
.new
Initializes the PRNG with initial seeds readed from system resources.
Class Method Summary
-
.secure
Returns an instamce of this PRNG with initial seeds readed from system resources.
Instance Method Summary
-
#jump_32(long : Bool = false) : self
Performs an advance over the 32-bit state.
-
#jump_64(long : Bool = false) : self
Performs an advance over the 64-bit state.
-
#next_u32 : UInt32
Generate a uniform-distributed random
UInt32
. -
#next_u64 : UInt64
Generate a uniform-distributed random
UInt64
.
Instance methods inherited from module Alea::PRNG(UInt32, UInt64)
next_f32 : Float32
next_f32,
next_f64 : Float64
next_f64,
next_i32 : Int32
next_i32,
next_i64 : Int64
next_i64,
next_u32 : UInt32
next_u32,
next_u64 : UInt64
next_u64
Constructor methods inherited from module Alea::PRNG(UInt32, UInt64)
new(seed32 : S32, seed64 : S64)
new
Constructor Detail
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::UndefinedError
if any ofseed32
orseed64
is negative.
Initializes the PRNG with initial seeds.
@parameters:
seed32
: value as input to init. the state of 32-bit generators ofprng
.seed64
: value as input to init. the state of 64-bit generators ofprng
.
Initializes the PRNG with initial seed.
@parameters:
seed
: initial seed as input for generating the state ofprng
.
Class Method Detail
Instance Method Detail
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^96
calls.
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^96
calls.
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