Abstract
Get the entire internal state of a generator
Abstract
randomGenerate a single random number on the interval [0, 1], updating whatever internal state the generator uses.
Set the seed of the generator; most generators should support this but RngStateBuiltin does not, and a cryptographically secure generator also may not.
Replace the entire internal state of a generator
Generated using TypeDoc
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 propertiesRngStateAlea: 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