Class RngStateAlea

Random number generator based on the "Alea" algorithm of Johannes Baagøe; designed to produce acceptable quality random numbers at a reasonable speed given limitations of JavaScript's numbers.

Hierarchy

Constructors

Methods

Constructors

  • new RngStateAlea(seed?: any, state?: number[]): RngStateAlea
  • The generator can be started from a "seed" (some small piece of data from which we'll derive a state) or from a state.

    Parameters

    • seed: any = null

      An initial seed; any truthy value will do. If not given (and if state is not given, then we seed using Math.random()

    • Optional state: number[]

      A state extracted from a previously initialised copy of an RngStateAlea generator; will be a length 4 array. If given, then seed must be null.

    Returns RngStateAlea

Methods

  • getState(): number[]
  • Get the entire internal state of a generator

    Returns number[]

  • random(): number
  • Generate a single random number on the interval [0, 1], updating whatever internal state the generator uses.

    Returns number

  • setSeed(seed: any): void
  • Set the seed of the generator; most generators should support this but RngStateBuiltin does not, and a cryptographically secure generator also may not.

    Parameters

    • seed: any

    Returns void

  • setState(state: number[]): void
  • Replace the entire internal state of a generator

    Parameters

    • state: number[]

    Returns void

Generated using TypeDoc