ArticleslgStudy

mathematics

Spectral test

Spectral test is a mathematics topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Spectral test rather than just read about it. In short: 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.

Spectral test — main illustration
Spectral test — illustration

Key takeaways

  • Spectral test belongs to mathematics; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Spectral test to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Spectral test from memory before moving on to harder problems.

Reference excerpt

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 u1,u2,…. Let 1/νt be the maximal separation between covering parallel planes of the sequence {(un+1:n+t)∣n=0,1,…}. The spectral test checks that the sequence ν2,ν3,ν4,… does not decay too quickly. Knuth recommends checking that each of the following five numbers is larger than 0.01: μ2=πν22/m,μ3=43πν33/m,μ4=12π2ν44/m,μ5=815π2ν55/m,μ6=16π3ν66/m, where m is the modulus of the LCG.

Figures of merit Knuth defines a figure of merit, which describes how close the separation 1/νt is to the theoretical minimum. Under Steele & Vigna's re-notation, for a dimension d, the figure fd is defined as fd(m,a)=νdγd1/2md, where a,m,νd are defined as before, and γd is the Hermite constant of dimension d. γd1/2md is the smallest possible interplane separation. L'Ecuyer 1991 further introduces two measures corresponding to the minimum of fd across a number of dimensions. Again under re-notation, ℳd+(m,a) is the minimum fd for a LCG from dimensions 2 to d, and ℳd∗(m,a) is the same for a multiplicative congruential pseudorandom number generator (MCG), i.e. one where only multiplication is used, or c=0. Steele & Vigna note that fd is calculated differently in these two cases, necessitating separate values. They further define a "harmonic" weighted average figure of merit, ℋd+(m,a) (and ℋd∗(m,a)).

Examples A small variant of the infamous RANDU, with xn+1=65539xnmod229, has:

The aggregate figures of merit are: ℳ8∗(65539,229)=0.018902, ℋ8∗(65539,229)=0.330886. George Marsaglia (1972) considers xn+1=69069xnmod232 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: ℳ8∗(69069,232)=0.313127, ℋ8∗(69069,232)=0.449578. 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 fd 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), 0x1dab5 (121525). ℳ8+=0.6403, ℋ8+=0.6588. For an MCG (c = 0), 0x1e92d (125229). ℳ8∗=0.6623, ℋ8∗=0.7497.

Additional illustration

References

Further reading Entacher, Karl (January 1998). "Bad subsequences of well-known linear congruential pseudorandom number generators". ACM Transactions on Modeling and Computer Simulation. 8 (1): 61–70. doi:10.1145/272991.273009. – lists the fd (notated as Ss in this text) of many well-known LCGs An expanded version of this work is available as: Entacher, Karl (2001). "A Collection of Selected Pseudorandom Number Generators With Linear Structures - extended version".

Illustrations

Spectral test: 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.
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.
Spectral test illustration
Spectral test illustration

Worked examples

Example 1 — a first encounter with Spectral test

Start with the simplest possible case. Write down what Spectral test claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In mathematics, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Spectral test before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Spectral test ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Spectral test

In research
Spectral test appears in mathematics research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Spectral test in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Spectral test is common in secondary-school and first-year university syllabi. It links to neighbouring topics Pseudorandom number generators, so understanding it makes those chapters shorter.
In everyday life
Look for Spectral test outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Spectral test” →

How to study Spectral test in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Spectral test means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Spectral test out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Spectral test in simple terms?

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.

Why does Spectral test matter?

Because it connects several mathematics ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Spectral test?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Spectral test.

Tags

  • Pseudorandom number generators

Keep exploring