Class Backports::Random::MT19937
In: lib/backports/random/bits_and_bytes.rb
lib/backports/random/MT19937.rb
Parent: Object

An implementation of Mersenne Twister MT19937 in Ruby

Methods

Constants

FLOAT_FACTOR = 1.0/9007199254740992.0
MASK_BY = [1,2,4,8,16]
STATE_SIZE = 624
LAST_STATE = STATE_SIZE - 1
PAD_32_BITS = 0xffffffff
LAST_31_BITS = 0x7fffffff
OFFSET = 397

Public Class methods

Convert an Integer seed of arbitrary size to either a single 32 bit integer, or an Array of 32 bit integers

Public Instance methods

Generates a completely new state out of the previous one.

Returns a random Integer from the range 0 … (1 << 32)

generates a random number on [0,1) with 53-bit resolution

Returns an integer within 0...upto

Seed must be either an Integer (only the first 32 bits will be used) or an Array of Integers (of which only the first 32 bits will be used)

No conversion or type checking is done at this level

[Validate]