Original version:
Mon Dec 30 11:38:45 2024
Last updates:
Thu Mar 27 16:05:32 2025
Mon Jul 7 10:33:40 2025
Wed Jul 9 10:48:22 2025
Fri Jul 11 07:29:48 2025
Fri Aug 15 06:54:07 2025
This Web site collects software, and test results, for evaluation of the quality of random-number generation. All files are freely available for use by others.
The file tuftests-2024.tar.gz is a bundle with the author's latest version of the Marsaglia/Tsang tuftests suite, with portability improvements, and support for simple one-line testing of about 50 or so random-number generators using tuftests, or with output to a file that can be used as input to Marsaglia's Diehard Battery test suite, or with one-line changes to the unigen*.c files, creating programs that can feed the Dieharder test suite.
Dieharder's home Web site is at https://webhome.phy.duke.edu/~rgb/General/dieharder.php, but it is not often necessary to build it from source code, because many operating-system binary package distributions already supply it. Here are some typical installation recipes, to be run by a system administrator (root) on Unix-like systems:
Alma/Fedora/Rocky/RedHat 8+: # dnf install dieharder-devel CentOS/RedHat 7: # yum install dieharder-devel Debian/Mint/Ubuntu: # apt-get install dieharder libdieharder-dev DragonFlyBSD/FreeBSD: # pkg install dieharder NetBSD: # pkgin install dieharder OpenBSD: # pkg_add dieharder
After downloading the bundle, unpack and build it like this:
% tar xfz tuftests-2024.tar.gz % cd tuftests-2024 % make
The Makefile comment header contains extensive comments on how to run selected, or all, tests on your system. Run times for each tuftests validation are about one minute on 2020-vintage workstations, under a minute for Diehard testing, and a half hour or so for Dieharder testing. Additional command line options capture streams of random numbers for display as 2-D and 3-D point plots. Such plots are generally not useful for quality assessment of generators, but can be helpful during testing of a new generator.
The Dieharder tests can be run for a particular generator like this, provided that a suitable function prototype is present in the unigen*.c file:
% cc -DUNIRAND=tyche64 tyche.c unigen64.c % ./a.out | dieharder -a -g 200 > tyche64.dieharder.report
Notable in this release is a new translation from Fortran 90 to C, in the file bcninc.c, of the Bailey–Crandall BCN generator that returns bit sequences from a provably normal number, meaning roughly that its digits are perfectly random. It can be used as a drop-in replacement for the Fortran code that is normally linked into the tuftests-2024 executable.
Chapter 7 of the author's book, The Mathematical-Function Computation Handbook, has an extensive discussion of random-number generation and testing, and its introduction enumerates properties that random-number software should have, but rarely does. When I recently reread that chapter, I found that there should be one more list item: if the generator returns IEEE 754 floating-point values, are subnormal numbers ever returned?
That book chapter also introduces the shuffle buffer technique for improving the quality, and period, of any given generator, and test results in the files okay/*shuffle* can be compared to see how much improvement is possible. The period lengthening from shuffling can be many orders of magnitude, solving the problem that many historical generators have, such as short periods of 2**32 or 2**64.
The okay subdirectory contains tuftest output for all the supported generators. That output shows that the Dyadkin–Hamilton urnd and Marsaglia xor_shift generators, both of which support families of hundreds of independent generators, all have serious correlation problems that are exposed by failures in the Gorilla test. They have both been touted in the literature as being of high quality, and offering fast execution.
The bcn, tyche, and xorwow generators pass all of the tuftests suite. So do the teagen ones, but they are notably slower than those others.
The probability of sequence overlap from long-period random-number generators, where the sequences are obtained from different starting seeds, has been investigated by Sebastiano Vigna. He shows that n streams of length L from a generator with period P have a probability of overlap that does not exceed n2 L / P. Thus, overlap will effectively never happen in practice with more recent generators with enormous periods, say 10100 or more.
The bundle dziala-1.0.0.tar.gz contains code for several new generators described in a not-yet-published (late 2024) article. It corrects some portability and C-interpretation issues, and augments the proposed generators with functions for seeding, and getting and setting generator state. The new generators are claimed to be among the fastest of previously published ones.
The bundle jones-1.0.0.tar.gz contains code from a Web site by David Jones at University College London, UK, that discusses desirable properties of generators, and offers code for several of them.
As with the Działa collection, the Jones code has been extended with additional capabilities, and validated on numerous operating systems and CPU architectures. Both should build flawlessly everywhere with modern C and C++ compilers.
Both the Działa and Jones packages have been augmented with 128-bit generators, because that data size is now partially supported by major C and C++ compilers.
In a 2006 paper, noted random-number expert George Marsaglia exhibited C code for a 32-bit random-number generator with an enormous period of about 1039460, more than 1033000 times longer than that of the widely used Mersenne Twister. Marsaglia's code has been cleaned up for appearance and portability, and tested with several versions of the clang and gcc compilers, as well as several different static analyzers. Randomness of its output has been tested with the Dieharder package, and that report is contained in its cmwc4096.c source code file. The initial random state initialization is contained in cmwc4096.h.
The Dieharder report reports just one test (diehard_squeeze) as WEAK; the remaining 113 tests are all reported as PASSED. Compared to most other generators that I have tested with Dieharder, this is an outstanding success.
In thousands of passes over the 2**32 limit of 32-bit unsigned integers, tests showed that 2-element repetitions occur about once in 2**32, and the minimum value of 0 was also produced with that frequency. Both match the predicted probability. However, the maximum value reached is 0xffff_fffe (2**32 - 2), not the expected value of 0xffff_ffff. Thus, it appears that the generator range in [0x0, 0xffff_fffe]. That range must be known exactly when converting integer random numbers to floating-point values.
A follow-up test with 10**14 passes took 34h36m to run, and we would expect each random number to appear 10**14 / 2**32 ~= 23283 times: the minimum value of 0x0 was found 23273 times, and there were 23447 2-element repetitions. However, the maximum value remained at 0xffff_fffe.
If the initial seed, and 4096-element state, were embedded in a family of generators, it could provide an (in practice) unlimited number of independent streams of random numbers for parallel execution, where those streams have effectively zero probability of overlap due to the enormous period.
A candidate implementation of such a generator family is supplied in cmwc4096-family.c. You create generator streams with dynamically generated state from user-supplied unique seeds (perhaps as simple as 0, 1, 2, 3, …) using state[k] = cmwc4096_family_create(seed[k]), sample the streams in parallel with random_value = cmwc4096_family(state[k]), and when done, free the states with cmwc4096_family_destroy(state[k]). The state[k] array contains opaque void * pointers, hiding all state details, including the size of the state, from user code.
There are 2**32 (about 4.29e9) possible family members, far more than could be used in parallel in current computer technologies.
The internal state includes canaries that identify valid data, and the code checks them on each use of the state. Invalid state causes immediate job termination with an error message on stderr, and a failing job error code.
Dieharder tests of each of 32 separate streams found no reports of FAILURE, and 1 to 9 reports of WEAK in 29 of the streams. Reports from 3 of the streams had all tests labeled as PASSED.
The author maintains an extensive, and frequently updated, bibliography of publications on random-number generation and testing at http://www.math.utah.edu/pub/tex/bib/index-table-p.html#prng. In mid 2025, it contains nearly 4300 entries from almost 600 journals, from 1900 to 2025. Its updates come from a growing archive of more than two million publications in several areas of computational science and mathematics from more than 8750 journals.