class Alea::MT19937
- Alea::MT19937
- Reference
- Object
Overview
MT19937
engine is an implementation of the famous
Mersenne Twister, developed by Makoto
Matsumoto and Takuji Nishimura: the most widely used PRNG passing most strict statistical tests.
- period: (2^19937)-1
- init: `Alea::Core::Knuth32`
Included Modules
Defined in:
Constant Summary
-
LOWER_MASK =
2147483647_u64
-
MATRIX_A =
2567483615_u64
-
STATE_LEN_M =
397
-
STATE_LEN_N =
624
-
TEMPERING_B =
2636928640_u64
-
TEMPERING_C =
4022730752_u64
-
UPPER_MASK =
2147483648_u64
Constructors
-
.new(seed32 : UInt32, seed64 : UInt32)
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
-
#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, UInt32)
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, UInt32)
new(seed32 : S32, seed64 : S64)
new
Constructor Detail
Initializes the PRNG with initial seeds.
@parameters:
seed32
: value as input to initialize the state of 32-bit generators.seed64
: value as input to initialize the state of 64-bit generators.
@references:
Alea::Core::Knuth32(624)#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
Generate a uniform-distributed random UInt32
.
@examples:
rng = Alea::MT19937.new
rng.next_u32 # => 2604272037
Generate a uniform-distributed random UInt64
.
@examples:
rng = Alea::MT19937.new
rng.next_u64 # => 11185263231290389851