I am playing around with PRNGs (like Mersenne Twister and rand()
function of stdlib) and I would want a good test that would help me ascertain the quality of random data produced by the PRNGs.
I have calculated the value of Pi using random numbers generated by the PRNGs, and I find rand()
and Mersenne Twister to be very close to offer a distinction (do I need to scrutinize after 10 decimal points?).
I do not have much idea about Monte Carlo simulations; please let me know about some algorithm/application (possibly something simple yet which could provide good inferences) that would help me distinguish them in terms of quality.
EDIT 1: I didn't notice before, but there is a similar thread: How to test random numbers?
EDIT 2: I am not able to interprete the results of NIST, as mentioned in one of the comments. I got this idea of visually interpreting the pattern (if any) from random.org and am following that because of it's simplicity. I would be very glad if someone could comment on the process of my testing:
(round(genrand_real1() / rand_0_1()))
then red pixel, else blackAs I understand that this is not a very precise solution, but if this provides a reasonable estimate, then I could live with this at the present moment.
One quick and easy way to determine the quality of a random number generator is to create a quick visual test. Human brains are pretty good at recognizing patterns. Visuals can give you a great snapshot test to see general patterns you might miss dredging through spreadsheets and numbers.
Hypothesis: To test the run test of randomness, first set up the null and alternative hypothesis. In run test of randomness, null hypothesis assumes that the distributions of the two continuous populations are the same. The alternative hypothesis will be the opposite of the null hypothesis.
It is necessary to test random numbers because the random numbers we generate are pseudo random numbers and not real and pseudo random number generator must generate a sequence of such random numbers which are uniformly distributed and they should not be correlated, they should not repeat itself.
There are several statistical tests suites available. I wrote, copied, and otherwise gathered together 120 PRNGs and tested each with a variety of tests suites given 4 hours per PRNG per test suite:
How many of those were in PRNGs that the other test suites all missed?
In short, only PractRand, TestU01, and possibly RaBiGeTe are worth using.
Full disclosure: I wrote PractRand, so either the set of PRNGs or any other non-qualitative measure could be biased in its favor.
Miscellaneous advantages:
Miscellaneous disadvantages:
The set of PRNGs tested: The PRNG set includes 1 large GFSR, 1 large LFSR, 4 xorshift type PRNGs, 2 xorwow type PRNGs, 3 other not-quite-LFSR PRNGs. It includes 10 simple power-of-2 modulus LCGs (which discard low bits to reach acceptable quality levels), 10 power-of-2 modulus not-quite-LCGs, and 9 combination generators based primarily around LCGs and not-quite-LCGs. It includes 19 reduced strength versions of CSPRNGs, plus one full strength CSPRNG. Of those, 14 were based upon indirection / dynamic s-boxes (e.g. RC4, ISAAC), four were ChaCha/Salsa parameterizations, and the remaining 2 were Trivium variants. It includes 11 PRNGs broadly classifiable as LFib-type or similar, not counting the LFSRs/GFSRs. The rest (about 35) were small state chaotic PRNGs, of which 10 used multiplication and the others were limited to arithmetic and bitwise logic.
Edit: There is also the test set in gjrand, which is very obscure and a little odd, but actually does extremely well.
Also, all of the PRNGs tested are included as non-recommended PRNGs in PractRand.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With