Skip to content

Replace Mersenne Twister with PCG

Original Reporter info from Mantis: runewalsh
  • Reporter name:

Description:

This paper: https://arxiv.org/pdf/1910.06437.pdf (see '10. Conclusion') and articles on https://www.pcg-random.org/ promote an idea that Mersenne Twister has severe flaws despite huge (2 KB) state. In particular, huge state size is both a flaw on its own (https://www.pcg-random.org/posts/too-big-to-fail.html) and is one of the reasons for some other flaws like sluggish decorrelation (see chapters of the paper before 'Conclusion').

Meanwhile, PCG-64-32-XSH-RR with period 2^64:
— has outstanding statistical performance. With stronger tempering function, RXS-M-XS (randomized xorshift + multiply + xorshift), it passes all modern statistical tests with only 36 bits of state, which is a theoretical minimum, see https://www.pcg-random.org/paper.html. Weaker but faster tempering intended for everyday use, XSH-RR (xorshift + randomized rotate), still passes same tests with 39 bits of state and has plenty of safety margin with conventional 64 bits.
— is very easy to code
— is very fast. At least it is definitely faster than non-SIMD Mersenne Twister.
— has minimal memory footprint (one to two uints64, one is a state and another is a stream-selecting constant if multiple streams are desired).

Changing the RNG would break current RandSeed sequences, but..?

Mantis conversion info:

  • Mantis ID: 38237
  • Monitored by: » @CuriousKit (J. Gareth Moreton)
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information