The LCG failed straight away, MWC failed at 64MB, Vigna & Blackman's RNGs failed straight away, Mersenne Twister failed at 512GB and the PCG fran through to 16TB.

Clearly, PCG is head and shoulders above the rest from a quality perspective and it is also quite fast. PractRand's author and I got 32-bit Mersenne Twister failing at 256GB. 256GB is a lot of random numbers and considering Mersenne Twister is over 20 years old it is still holding its own today; although a bit slow by modern standards. There is a small bias in Mersenne Twister but PractRand is not picking it up until we get past 128GB. Mersenne Twister does better in other tests but PractRand has developed a reputation for not taking prisoners.

Here is a test, on bits not bytes, of an LCG (Numerical Recipes) using Fourmilab's ENT.

Code: Select all

`Entropy = 1.000000 bits per bit.`

Optimum compression would reduce the size

of this 33554432 bit file by 0 percent.

Chi square distribution for 33554432 samples is 0.06, and randomly

would exceed this value 81.04 percent of the times.

Arithmetic mean value of data bits is 0.5000 (0.5 = random).

Monte Carlo value for Pi is 3.142842429 (error 0.04 percent).

Serial correlation coefficient is -0.000119 (totally uncorrelated = 0.0).

Nothing apparently untoward there but LCGs have a heavy bias and ENT is not sophisticated enough to spot it.

My problem with PractRand has been that the first hurdle requires multiple MB of data and I have wanted it to start with a much lower hurdle.

I have found a switch we can use after stdin: -tlmin <N>KB where N is the 'height' of the first hurdle. So, we can use something like this: My_RNG.exe | RNG_test.exe stdin -tlmin 1KB.

I tested a few LCGs and they failed at 8KB. FreeBASIC's generator #2 failed at 4KB.

These are very small hurdles but if you have a graphics program requiring up to 2000, or so, random numbers for initialization purposes then even PractRand won't fault you for using FreeBASIC's generator #2. You will not need any of my 'sophisticated' generators and FB's #2 is marginally faster than my fastest.

I should mention that MWC is Marsaglia's initial foray into a new type of PRNG. My CMWC4096 is a Complimentary Multiply With Carry, lag~4096 base 2^32-1 and that went to 2TB with PractRand.

If you need more than 4KB of random numbers of good quality then do not use a LCG because you will not get them.

As a final note, I have to admit that being a purist I still cannot bring myself to using an LCG. I have a light version of PCG32II which does nothing other than knock out [0,1) numbers. <smile>