TestU01 is a software library, implemented in the ANSI C language, that offers a collection of utilities for the empirical statistical testing of uniform random number generators (RNGs). The library was first introduced in 2007 by Pierre L'Ecuyer and Richard Simard of the Université de Montréal.
Overview
TestU01 provides general implementations of classical statistical tests for random number generators, as well as several other tests proposed in the literature and some original ones. These tests can be applied to generators predefined in the library, user-defined generators, and streams of random numbers stored in files. The library also includes specific test suites for sequences of uniform random numbers in the interval [0,1] and for bit sequences, along with basic tools for plotting vectors of points produced by generators.
History
An initial battery of randomness tests for RNGs was suggested in the 1969 first edition of The Art of Computer Programming by Donald Knuth. Knuth's tests were later supplanted by George Marsaglia's Diehard tests (1996), which consisted of fifteen different tests. The inability to modify test parameters or add new tests in the Diehard suite led to the development of the TestU01 library.
Features
TestU01 offers four groups of modules for analyzing RNGs:
- Implementing (pre-programmed) RNGs;
- Implementing specific statistical tests;
- Implementing batteries of statistical tests;
- Applying tests to entire families of RNGs.
When a specific test is applied to a sample of size n produced by an RNG, the p-value of the test usually remains reasonable as the sample size increases until the sample size reaches a threshold n₀. After that point, the p-value diverges to 0 or 1 with exponential speed. Module 4 allows researchers to study the interaction between a specific test and the structure of the point sets produced by a given family of RNGs, which can be used to determine how large the sample size should be, as a function of the generator's period length, before the generator begins to fail the test systematically.
TestU01 offers several batteries of tests, including "Small Crush" (10 tests), "Crush" (96 tests), and "Big Crush" (106 tests). On a 1.7 GHz Pentium 4 running Red Hat Linux 9.0, for a simple RNG, Small Crush takes about 2 minutes, Crush about 1.7 hours, and Big Crush about 4 hours. For more complex RNGs, these times increase by a factor of two or more. For comparison, the Diehard tests take about 15 seconds to run.
Limitations
TestU01 only accepts 32-bit inputs and interprets them as values in the range [0, 1]. This causes it to be more sensitive to flaws in the most-significant bits than in the least-significant bits. It is therefore important to test general-purpose generators in bit-reversed form to verify their suitability for applications that use the low-order bits. Generators that produce 64 bits of output additionally require separate tests for their high and low halves.
Publication
The library was formally described in the paper "TestU01: A C Library for Empirical Testing of Random Number Generators," published in ACM Transactions on Mathematical Software (Vol. 33, article 22, 2007) by Pierre L'Ecuyer and Richard Simard. The paper also provides a survey and classification of statistical tests for RNGs and applies the test batteries to a long list of widely used generators.