Spectral test

Last updated
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. Randu.png
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.

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.

Contents

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 being 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)

d2345678
ν2
d
536936458118116116116
μd3.1410−510−410−30.02
fd [lower-alpha 1] 0.5202240.0189020.0841430.2071850.3688410.5522050.578329

The aggregate figures of merit are: , . [lower-alpha 1]

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]

d2345678
ν2
d
42432098562072544528046990242
μd [lower-alpha 2] 3.102.913.205.010.017
fd [lower-alpha 1] 0.4624900.3131270.4571830.5529160.3767060.4966870.685247

The aggregate figures of merit are: , . [lower-alpha 1]

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:

Additional illustration

Spectral test of 3x mod 31.png
Spectral test of 13x mod 31.png
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.

Related Research Articles

<span class="mw-page-title-main">Electroweak interaction</span> Unified description of electromagnetism and the weak interaction

In particle physics, the electroweak interaction or electroweak force is the unified description of two of the four known fundamental interactions of nature: electromagnetism (electromagnetic interaction) and the weak interaction. Although these two forces appear very different at everyday low energies, the theory models them as two different aspects of the same force. Above the unification energy, on the order of 246 GeV, they would merge into a single force. Thus, if the temperature is high enough – approximately 1015 K – then the electromagnetic force and weak force merge into a combined electroweak force. During the quark epoch (shortly after the Big Bang), the electroweak force split into the electromagnetic and weak force. It is thought that the required temperature of 1015 K has not been seen widely throughout the universe since before the quark epoch, and currently the highest human-made temperature in thermal equilibrium is around 5.5x1012 K (from the Large Hadron Collider).

<span class="mw-page-title-main">Normal distribution</span> Probability distribution

In statistics, a normal distribution or Gaussian distribution is a type of continuous probability distribution for a real-valued random variable. The general form of its probability density function is

A pseudorandom number generator (PRNG), also known as a deterministic random bit generator (DRBG), is an algorithm for generating a sequence of numbers whose properties approximate the properties of sequences of random numbers. The PRNG-generated sequence is not truly random, because it is completely determined by an initial value, called the PRNG's seed. Although sequences that are closer to truly random can be generated using hardware random number generators, pseudorandom number generators are important in practice for their speed in number generation and their reproducibility.

<span class="mw-page-title-main">Linear congruential generator</span> Algorithm for generating pseudo-randomized numbers

A linear congruential generator (LCG) is an algorithm that yields a sequence of pseudo-randomized numbers calculated with a discontinuous piecewise linear equation. The method represents one of the oldest and best-known pseudorandom number generator algorithms. The theory behind them is relatively easy to understand, and they are easily implemented and fast, especially on computer hardware which can provide modular arithmetic by storage-bit truncation.

<span class="mw-page-title-main">Stress–energy tensor</span> Tensor describing energy momentum density in spacetime

The stress–energy tensor, sometimes called the stress–energy–momentum tensor or the energy–momentum tensor, is a tensor physical quantity that describes the density and flux of energy and momentum in spacetime, generalizing the stress tensor of Newtonian physics. It is an attribute of matter, radiation, and non-gravitational force fields. This density and flux of energy and momentum are the sources of the gravitational field in the Einstein field equations of general relativity, just as mass density is the source of such a field in Newtonian gravity.

<span class="mw-page-title-main">Student's t-distribution</span> Probability distribution

In probability and statistics, Student's t distribution is a continuous probability distribution that generalizes the standard normal distribution. Like the latter, it is symmetric around zero and bell-shaped.

<span class="mw-page-title-main">RANDU</span>

RANDU is a linear congruential pseudorandom number generator (LCG) of the Park–Miller type, which was used primarily in the 1960s and 1970s. It is defined by the recurrence:

The Einstein–Hilbert action in general relativity is the action that yields the Einstein field equations through the stationary-action principle. With the (− + + +) metric signature, the gravitational part of the action is given as

In quantum field theory, the theta vacuum is the semi-classical vacuum state of non-abelian Yang–Mills theories specified by the vacuum angleθ that arises when the state is written as a superposition of an infinite set of topologically distinct vacuum states. The dynamical effects of the vacuum are captured in the Lagrangian formalism through the presence of a θ-term which in quantum chromodynamics leads to the fine tuning problem known as the strong CP problem. It was discovered in 1976 by Curtis Callan, Roger Dashen, and David Gross, and independently by Roman Jackiw and Claudio Rebbi.

In general relativity, the Gibbons–Hawking–York boundary term is a term that needs to be added to the Einstein–Hilbert action when the underlying spacetime manifold has a boundary.

Tensor–vector–scalar gravity (TeVeS), developed by Jacob Bekenstein in 2004, is a relativistic generalization of Mordehai Milgrom's Modified Newtonian dynamics (MOND) paradigm.

In theoretical physics, massive gravity is a theory of gravity that modifies general relativity by endowing the graviton with a nonzero mass. In the classical theory, this means that gravitational waves obey a massive wave equation and hence travel at speeds below the speed of light.

In theoretical physics, a source field is a background field coupled to the original field as

A theoretical motivation for general relativity, including the motivation for the geodesic equation and the Einstein field equation, can be obtained from special relativity by examining the dynamics of particles in circular orbits about the Earth. A key advantage in examining circular orbits is that it is possible to know the solution of the Einstein Field Equation a priori. This provides a means to inform and verify the formalism.

<span class="mw-page-title-main">Covariant formulation of classical electromagnetism</span> Ways of writing certain laws of physics

The covariant formulation of classical electromagnetism refers to ways of writing the laws of classical electromagnetism in a form that is manifestly invariant under Lorentz transformations, in the formalism of special relativity using rectilinear inertial coordinate systems. These expressions both make it simple to prove that the laws of classical electromagnetism take the same form in any inertial coordinate system, and also provide a way to translate the fields and forces from one frame to another. However, this is not as general as Maxwell's equations in curved spacetime or non-rectilinear coordinate systems.

In 3-dimensional topology, a part of the mathematical field of geometric topology, the Casson invariant is an integer-valued invariant of oriented integral homology 3-spheres, introduced by Andrew Casson.

Lagrangian field theory is a formalism in classical field theory. It is the field-theoretic analogue of Lagrangian mechanics. Lagrangian mechanics is used to analyze the motion of a system of discrete particles each with a finite number of degrees of freedom. Lagrangian field theory applies to continua and fields, which have an infinite number of degrees of freedom.

In string theory, the Ramond–Neveu–Schwarz (RNS) formalism is an approach to formulating superstrings in which the worldsheet has explicit superconformal invariance but spacetime supersymmetry is hidden, in contrast to the Green–Schwarz formalism where the latter is explicit. It was originally developed by Pierre Ramond, André Neveu and John Schwarz in the RNS model in 1971, which gives rise to type II string theories and can also give type I string theory. Heterotic string theories can also be acquired through this formalism by using a different worldsheet action. There are various ways to quantize the string within this framework including light-cone quantization, old canonical quantization, and BRST quantization. A consistent string theory is only acquired if the spectrum of states is restricted through a procedure known as a GSO projection, with this projection being automatically incorporated in the Green–Schwarz formalism.

<span class="mw-page-title-main">Marsaglia's theorem</span> Describes flaws with the pseudorandom numbers from a linear congruential generator

In computational number theory, Marsaglia's theorem connects modular arithmetic and analytic geometry to describe the flaws with the pseudorandom numbers resulting from a linear congruential generator. As a direct consequence, it is now widely considered that linear congruential generators are weak for the purpose of generating random numbers. Particularly, it is inadvisable to use them for simulations with the Monte Carlo method or in cryptographic settings, such as issuing a public key certificate, unless specific numerical requirements are satisfied. Poorly chosen values for the modulus and multiplier in a Lehmer random number generator will lead to a short period for the sequence of random numbers. Marsaglia's result may be further extended to a mixed linear congruential generator.

In theoretical physics, more specifically in quantum field theory and supersymmetry, supersymmetric Yang–Mills, also known as super Yang–Mills and abbreviated to SYM, is a supersymmetric generalization of Yang–Mills theory, which is a gauge theory that plays an important part in the mathematical formulation of forces in particle physics.

References

  1. 1 2 3 4 Calculated using software from Steele & Vigna (2020), program "mspect" (src/spect.cpp, multiplicative mode).
  2. Calculated from ν2
    d
    reported by Marsaglia.
  1. Williams, K. B.; Dwyer, Jerry (1 Aug 1996), "Testing Random Number Generators, Part 2", Dr. Dobb's Journal , retrieved 26 Jan 2012.
  2. Marsaglia, George (September 1968). "Random Numbers Fall Mainly in the Planes" (PDF). PNAS . 61 (1): 25–28. Bibcode:1968PNAS...61...25M. doi: 10.1073/pnas.61.1.25 . PMC   285899 . PMID   16591687.
  3. Jain, Raj. "Testing Random-Number Generators (Lecture)" (PDF). Washington University in St. Louis . Retrieved 2 December 2016.
  4. 1 2 Knuth, Donald E. (1981), "3.3.4: The Spectral Test", The Art of Computer Programming volume 2: Seminumerical algorithms (2nd ed.), Addison-Wesley .
  5. IBM, System/360 Scientific Subroutine Package, Version II, Programmer's Manual, H20-0205-1, 1967, p. 54.
  6. International Business Machines Corporation (1968). "IBM/360 Scientific Subroutine Package (360A-CM-03X) Version III" (PDF). Stan's Library. White Plains, NY: IBM Technical Publications Department. II: 77. doi:10.3247/SL2Soft08.001. Scientific Application Program H20-0205-3.
  7. 1 2 3 4 5 6 7 Steele, Guy L. Jr.; Vigna, Sebastiano (February 2022) [15 January 2020]. "Computationally easy, spectrally good multipliers for congruential pseudorandom number generators" (PDF). Software: Practice and Experience. 52 (2): 443–458. arXiv: 2001.05304 . doi: 10.1002/spe.3030 . Associated software and data at https://github.com/vigna/CPRNG.
  8. L'Ecuyer, Pierre (January 1999). "Tables of Linear Congruential Generators of Different Sizes and Good Lattice Structure" (PDF). Mathematics of Computation . 68 (225): 249–260. Bibcode:1999MaCom..68..249L. CiteSeerX   10.1.1.34.1024 . doi:10.1090/S0025-5718-99-00996-5. Be sure to read the Errata as well.
  9. Marsaglia, GEORGE (1972-01-01), Zaremba, S. K. (ed.), "The Structure of Linear Congruential Sequences", Applications of Number Theory to Numerical Analysis, Academic Press, pp. 249–285, ISBN   978-0-12-775950-0 , retrieved 2024-01-29

Further reading