Spectral test

Statistical test for linear congruential generators From Wikipedia, the free encyclopedia

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.

Thumb
Three-dimensional plot of 100,000 values generated with RANDU. Each point represents 3 consecutive pseudorandom values. It is clearly seen that the points fall in 15 two-dimensional planes.

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]:3 where are defined as before, and is the Hermite constant of dimension d. is the smallest possible interplane separation.[7]:3

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]:13 They further define a "harmonic" weighted average figure of merit, (and ).[7]:13

Examples

A small variant of the infamous RANDU, with has:[4]:(Table 1)

More information d, ν2d ...
d 2345678
ν2
d
536936458118116116116
μd 3.1410−510−410−30.02
fd[a] 0.5202240.0189020.0841430.2071850.3688410.5522050.578329
Close

The aggregate figures of merit are: , .[a]

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]

More information d, ν2d ...
d 2345678
ν2
d
42432098562072544528046990242
μd[b] 3.102.913.205.010.017
fd[a] 0.4624900.3131270.4571830.5529160.3767060.4966870.685247
Close

The aggregate figures of merit are: , .[a]

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]:14–5 For example, they report that the best 17-bit a for m = 232 is:

  • For an LCG (c 0), 0x1dab5 (121525). , .[7]:14
  • For an MCG (c = 0), 0x1e92d (125229). , .[7]:14

Additional illustration

Thumb
Thumb
Despite the fact that both relations pass the Chi-squared test, the first LCG is less random than the second, as the range of values it can produce by the order it produces them in is less evenly distributed.

References

Further reading

Loading related searches...

Wikiwand - on

Seamless Wikipedia browsing. On steroids.