Spectral test
The spectral test is a statistical test for the quality of a class of pseudorandom number generators (PRNGs), the linear congruential generators (LCGs). LCGs have a property that when plotted in 2 or more dimensions, lines or hyperplanes will form, on which all possible outputs can be found. The spectral test compares the distance between these planes; the further apart they are, the worse the generator is. As this test is devised to study the lattice structures of LCGs, it can not be applied to other families of PRNGs.

According to Donald Knuth, this is by far the most powerful test known, because it can fail LCGs which pass most statistical tests. The IBM subroutine RANDU LCG fails in this test for 3 dimensions and above.

Let the PRNG generate a sequence . Let  be the maximal separation between covering parallel planes of the sequence . The spectral test checks that the sequence  does not decay too quickly.

Knuth recommends checking that each of the following 5 numbers is larger than 0.01. where  is the modulus of the LCG.

Figures of merit 
Knuth defines a figure of merit, which describes how close the separation   is to the theoretical minimum. Under Steele & Vigna's re-notation, for a dimension , the figure  is defined as:

,

where  are defined as before, and  being the Hermite constant of dimension d.  is the smallest possible interplane separation.

L'Ecuyer 1991 further introduces two measures corresponding to the minimum of  across a number of dimensions. Again under re-notation,  is the minimum  for a LCG from dimensions 2 to , and  is the same for a multiplicative congruential pseudorandom number generator (MCG), i.e. one where only multiplication is used, or . Steele & Vigna note that the  is calculated differently in these two cases, necessitating separate values. They further define a "harmonic" weighted average figure of merit,  (and ).

Examples 
A small variant of the infamous RANDU, with  has:

The aggregate figures of merit are: , .

George Marsaglia (1972) considers  as "a candidate for the best of all multipliers" because it is easy to remember, and has particularly large spectral test numbers.

The aggregate figures of merit are: , .

Steele & Vigna (2020) provide the multipliers with the highest aggregate figures of merit for many choices of m = 2n and a given bit-length of a. They also provide the individual  values and a software package for calculating these values. For example, they report that the best 17-bit a for m = 232 is:

 For an LCG (c ≠ 0),  (121525). , .
 For an MCG (c = 0),  (125229). , .

Additional illustration

References

Further reading 
  – lists the  (notated as  in this text) of many well-known LCGs
 An expanded version of this work is available as: 

Pseudorandom number generators