There are many now quite venerable and newer test suites that will check the quality of random number generators but none of them are particularly easy to install and use:
This repo provides a nix-shell which will build dieharder, TestU01 and PractRand and allow you (in the nix shell) to use them almost all identically with the minimum amount of fuss.
Optionally, this repo contains a Haskell program that will generate a stream of random numbers from some of the Haskell random number generator implementations. See generate/README.md for details.
-
Enter the test environment containing only the PRNG test batteries:
nix-shell https://github.com/tweag/random-quality/archive/master.tar.gz
To test that the environment is set up correctly, run:
RNG_test stdin32 < /dev/zeroThis should show a spectacularly failed test:
/dev/zerois not a good PRNG. See Tests for details. -
Alternatively, enter the test environment containing the PRNG test batteries as well as a number of Haskell PRNGs:
nix-shell https://github.com/tweag/random-quality/archive/master.tar.gz \ --arg buildHaskell trueTo test that the environment is set up correctly, run:
generate random-word32 | RNG_test stdin32The whole test takes a long time, you can cancel it with Ctrl+C. This uses the
randomlibrary to generate a sequence of random numbers. See Generators and Tests for details.
The following randomness test suites are available in the repository via Nix, all of which accept a stream of random numbers on stdin:
- dieharder: run
dieharder -a -g200to execute all available tests (-a). Seedieharder -hfor more options. - PractRand: run via
RNG_test stdin32to test a stream of 32-bit random numbers. SeeRNG_test -helpfor details. - TestU01: run via
TestU01_stdin -[s|c|b], which expects a stream of 32-bit random numbers. Three test batteries are available:-sstarts SmallCrush,-cstarts Crush,-bstarts BigCrush. - gjrand: run via
pmcpto execute the standard test size (1 GB) on ints, andpmcpfto test double precision floating point numbers. Seepmcp -handpmcpf -hfor options. - rademacher-fpl: run via
detect-significand-biasto execute the standard test size (10 MB) on double precision floating point numbers.