Class RngStateObserved

Basic random number state class, to be passed to distribution functions (e.g., normal. The base class does not implement any draws though, so use a specialisation such as RngStateBuiltin or create a less terrible one.

We provide several concrete state clases that can be used:

  • RngStateBuiltin: Uses Math.random() and can't be seeded, saved, restored and has dubious statistical and predictibility properties

  • RngStateAlea: Uses the "Alea" algorithm, and can be seeded, saved, restored and has better statistical properties (but is still predictable)

  • RngStateObserved: Wraps any RngState-implementing class and allows observation of the draws, useful for testing.

  • RngStateReplay: Replays the state of any observed state

Hierarchy

Constructors

Methods

  • getState(): any
  • Get the entire internal state of a generator

    Returns any

  • length(): number
  • The number of random number draws available to replay.

    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: any): void
  • Replace the entire internal state of a generator

    Parameters

    • state: any

    Returns void

  • values(): readonly number[]
  • The array of values drawn by this generator

    Returns readonly number[]

Generated using TypeDoc