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.
Generate a single random number on the interval [0, 1],
updating whatever internal state the generator uses.
Returns number
setSeed
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.
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