Spacing Distribution of Random Numbers
This Demonstration shows that the spacing distribution of a sorted sequence of random numbers sampled from a uniform probability distribution in the interval always follows an exponential (Poisson) distribution. This is a fundamental result in the spectral theory of random matrices (from random matrix theory), since the eigenvalue spectra of quantum systems with regular classical counterparts have Poisson-level spacing distributions [1, 2].[more]
Use the slider to set the number of generated random numbers. The normalized spacings are then fitted to an exponential distribution to find the value of the decay parameter using the built-in Wolfram Language function FindDistributionParameters; the goodness-of-fit test is performed using the DistributionFitTest object function and related options used in the code; in particular, use the radio buttons to choose among six different statistical tests available for the fitted distribution.[less]
Snapshot 1: same as thumbnail image but with the Anderson–Darling test applied to exponential fitting on 1000 random numbers
Snapshot 2: the Kolmogorov–Smirnov test applied to exponential fitting on 50 random numbers
Snapshot 3: the Pearson chi square test applied to exponential fitting on 5000 random numbers
 M. V. Berry, M. Tabor and J. M. Ziman, "Level Clustering in the Regular Spectrum," Proceedings of the Royal Society of London. A. Mathematical and Physical Sciences, 356(1686), 1977 pp. 375–394. doi:10.1098/rspa.1977.0140.
 T. Timberlake, "Random Numbers and Random Matrices: Quantum Chaos Meets Number Theory," American Journal of Physics, 74(6), 2006 pp. 547–553. doi:10.1119/1.2198883.