Rng
case Rng(Int64)A pseudo-random number generator, as a value.
Randomness is deliberately data rather than an effect. A generator is threaded through
step like any other part of the world, which means a simulation that uses randomness is
still a pure function of its inputs. Replaying a recorded input script from the same seed
therefore produces a bit-identical result, with no handler to install and no shared
generator to reason about across threads.
This is a 64-bit linear congruential generator using the multiplier and increment from Knuth's MMIX. It is not cryptographic and is not meant to be.
Instances
Definitions
Returns true with probability 1 / oneIn, and the advanced generator.
Creates a generator from seed.
The state is advanced once so that adjacent seeds do not produce correlated first values, which is the usual failure mode of a bare LCG.
Returns a value in 0 ..< bound and the advanced generator.
A bound of zero or less yields 0, so callers never have to guard.
Returns the next 64-bit value and the advanced generator.