class Alea::MT19937

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

Class Method Summary

Instance Method Summary

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

def self.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:

@exceptions:


def self.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.

def self.new(seed : Int) #

Initializes the PRNG with initial seed.

@parameters:

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

def self.new #

Initializes the PRNG with initial seeds readed from system resources.


Class Method Detail

def self.secure #

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


Instance Method Detail

def next_u32 : UInt32 #

Generate a uniform-distributed random UInt32.

@examples:

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

def next_u64 : UInt64 #

Generate a uniform-distributed random UInt64.

@examples:

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