class

Alea::MT19937

Inherits Alea::PRNG < Reference < Object

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`

Constants

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.

@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 of seed32 or seed64 is negative.
Source
new(seed32 : Int, seed64 : Int)

Initializes the PRNG with initial seeds.

@parameters:

  • seed32: value as input to init. the state of 32-bit generators of prng.
  • seed64: value as input to init. the state of 64-bit generators of prng.
Source
new(seed : Int)

Initializes the PRNG with initial seed.

@parameters:

  • seed: initial seed as input for generating the state of prng.
Source
new

Initializes the PRNG with initial seeds readed from system resources.

Source

Class methods

secure

Returns an instamce of this PRNG with initial seeds readed from system resources.

Source

Instance methods

next_u32

Generate a uniform-distributed random UInt32.

@examples:

rng = Alea::MT19937.new
rng.next_u32 # => 2604272037
Source
next_u64

Generate a uniform-distributed random UInt64.

@examples:

rng = Alea::MT19937.new
rng.next_u64 # => 11185263231290389851
Source