| Safe Haskell | None |
|---|---|
| Language | GHC2021 |
Data.TypeLevel.PRNG.LCG
Description
Linear congruential generators (and Lehmer RNGs).
Documentation
data LCGNext (m :: Natural) (a :: Natural) (c :: Natural) (n :: FunKind Natural Natural) Source #
Calculate the next term in a linear congruential generator.
The previous term is given in n.
type MMIX = LCGNext (2 ^ 64) 6364136223846793005 1442695040888963407 Source #
Knuth's MMIX RNG. An LCG.
As I understand, the bits have a period of 2^n where n is their bit position. So the low bits have very low randomness: e.g. it flips between odd & even! Consider only using the top 32 bits.
data LehmerNext (m :: Natural) (a :: Natural) (n :: FunKind Natural Natural) Source #
Calculate the next term in a Lehmer random number generator (a type of linear congruential generator). A type of LCG.
The previous term is given in n.
Very few operations.
type MinstdRand = LehmerNext ((2 ^ 31) - 1) 48271 Source #
minstd_rand from C++11. A Lehmer RNG.
Seems pretty good. Low bits aren't as low period like many other LCGs.