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).[1] 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.[2] The spectral test compares the distance between these planes; the further apart they are, the worse the generator is.[3] 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,[4] this is by far the most powerful test known, because it can fail LCGs which pass most statistical tests. The IBM subroutine RANDU[5][6] 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[7]Template:Rp where are defined as before, and is the Hermite constant of dimension d. is the smallest possible interplane separation.[7]Template:Rp
L'Ecuyer 1991 further introduces two measures corresponding to the minimum of across a number of dimensions.[8] 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.[7]Template:Rp They further define a "harmonic" weighted average figure of merit, (and ).[7]Template:Rp
Examples
A small variant of the infamous RANDU, with has:[4]Template:Rp
| d | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
|---|---|---|---|---|---|---|---|
| νTemplate:Su | 536936458 | 118 | 116 | 116 | 116 | ||
| μd | 3.14 | 10−5 | 10−4 | 10−3 | 0.02 | ||
| fdTemplate:Efn | 0.520224 | 0.018902 | 0.084143 | 0.207185 | 0.368841 | 0.552205 | 0.578329 |
The aggregate figures of merit are: , .Template:Efn
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.[9]
| d | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
|---|---|---|---|---|---|---|---|
| νTemplate:Su | 4243209856 | 2072544 | 52804 | 6990 | 242 | ||
| μdTemplate:Efn | 3.10 | 2.91 | 3.20 | 5.01 | 0.017 | ||
| fdTemplate:Efn | 0.462490 | 0.313127 | 0.457183 | 0.552916 | 0.376706 | 0.496687 | 0.685247 |
The aggregate figures of merit are: , .Template:Efn
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.[7]Template:Rp For example, they report that the best 17-bit a for m = 232 is:
- For an LCG (c ≠ 0), Template:Tt (121525). , .[7]Template:Rp
- For an MCG (c = 0), Template:Tt (125229). , .[7]Template:Rp
Additional illustration
References
Template:Notelist Template:Reflist
Further reading
- Template:Cite journal – lists the (notated as in this text) of many well-known LCGs
- An expanded version of this work is available as: Template:Cite web
- ↑ Template:Citation.
- ↑ Template:Cite journal
- ↑ Template:Cite web
- ↑ 4.0 4.1 Template:Citation.
- ↑ IBM, System/360 Scientific Subroutine Package, Version II, Programmer's Manual, H20-0205-1, 1967, p. 54.
- ↑ Template:Cite journal
- ↑ 7.0 7.1 7.2 7.3 7.4 7.5 7.6 Template:Cite journal Associated software and data at https://github.com/vigna/CPRNG.
- ↑ Template:Cite journal Be sure to read the Errata as well.
- ↑ Template:Citation