While Lehmer’s multiplicative congruential generator is fast, it does NOT pass PractRand 0.94. In does it beat the minimal standard and too big to fail Melissa O’Neill tested these generators with PractRand 0.93, where they passed.
Consider an idea from George Marsaglia instead: save and add the “carry” of the multiplication, giving a multiply-with-carry generator:
This 64-bit generator passes the PractRand test suite (version 0.94) at least up to 4 TB!
See source and source for the code generated by GCC 8.2 and clang 7.0 respectively, plus VC source for an implementation using Microsofts Visual C compiler (which does not support a 128 bit integer type).
I used the latter for the PractRand test.
Stefan Kanthak wrote:
While Lehmer’s multiplicative congruential generator is fast, it does NOT pass PractRand 0.94. In does it beat the minimal standard and too big to fail Melissa O’Neill tested these generators with PractRand 0.93, where they passed.
Consider an idea from George Marsaglia instead: save and add the “carry” of the multiplication, giving a multiply-with-carry generator:
This 64-bit generator passes the PractRand test suite (version 0.94) at least up to 4 TB! See source and source for the code generated by GCC 8.2 and clang 7.0 respectively, plus VC source for an implementation using Microsofts Visual C compiler (which does not support a 128 bit integer type). I used the latter for the PractRand test.