A standalone, pure JavaScript implementation of the Mersenne Twister pseudo random number generator.

Constructors

  • Instantiates a new Mersenne Twister.

    Parameters

    • Optionalseed: number

      The initial seed value, if not provided the current timestamp will be used.

    Returns MersenneTwister

Methods

  • Generates a random unsigned 32-bit integer.

    Returns number

    0.1.0

  • Generates a random unsigned 31-bit integer.

    Returns number

    0.1.0

  • A pseudo-normal distribution using the Box-Muller transform.

    Parameters

    • mu: number

      The normal distribution mean

    • sigma: number

      The normal distribution standard deviation

    Returns number

  • Generates a random real in the interval [0;1[ with 32-bit resolution.

    Same as .rnd() method - for consistency with Math.random() interface.

    Returns number

    0.2.0

  • Generates a random real in the interval [0;1] with 32-bit resolution.

    Returns number

    0.1.0

  • Generates a random real in the interval ]0;1[ with 32-bit resolution.

    Returns number

    0.1.0

  • Generates a random real in the interval [0;1[ with 32-bit resolution.

    Returns number

    0.1.0

  • Generates a random real in the interval [0;1[ with 53-bit resolution.

    Returns number

    0.1.0

  • Initializes the state vector by using one unsigned 32-bit integer "seed", which may be zero.

    Parameters

    • seed: number

      The seed value.

    Returns number

    0.1.0

  • Initializes the state vector by using an array key[] of unsigned 32-bit integers of the specified length. If length is smaller than 624, then each array of 32-bit integers gives distinct initial state vector. This is useful if you want a larger seed space than 32-bit word.

    Parameters

    • vector: array

      The seed vector.

    Returns void

    0.1.0

  • A factory method for generating random normal rolls

    Parameters

    • ...args: any[]

    Returns number

  • A factory method for generating random uniform rolls

    Returns number