John von Neumann's First Pseudorandom Number Generator
Requires a Wolfram Notebook System
Interact on desktop, mobile and cloud with the free Wolfram Player or other Wolfram Language products.
Pseudorandom number generators have applications in many areas: simulation, game-playing, cryptography, statistical sampling, evaluation of multiple integrals, and computations in statistical physics, to name a few.[more]
The method illustrated in this Demonstration, known as the middle-square method, is a generalization of the first computer-based pseudorandom number generator (PRNG). John von Neumann suggested it in 1946 for the purpose of devising, together with Stan Ulam, what would later become known as the Monte Carlo method for the simulation of physical processes, motivated by their work at Los Alamos National laboratory while building the atomic bomb.
Iterating von Neumann's procedure produces a series of numbers generated by a deterministic process intended merely to imitate a random sequence. The procedure is very simple:
1. take any -digit number
2. square it
3. take the middle digits of the resulting number as the "random number"
4. use that number as the seed for the next iteration
Of course there are at most only different numbers, so eventually the whole sequence repeats in the same order and eventually a number comes up that was squared before. Another flaw is when the sequence reaches 000…, from which all squares from then on are 0 and the resulting sequences (after padding) are also 0. In other words, the method eventually reaches a fixed point. One way to avoid this is to pad with 1s rather than 0s, as was done in this Demonstration.
Each iteration starts from a random seed and produces a sequence of sequences of numbers generating the grid shown. The irregularity of the grid shows that the procedure succeeds in producing a random-looking output in spite of the simplicity and deterministic nature of the procedure.
John von Neumann himself joked about it: "Anyone who considers arithmetical methods of producing random digits is, of course, in a state of sin."[less]
Contributed by: Hector Zenil (March 2011)
Open content licensed under CC BY-NC-SA
J. von Neumann, "Various Techniques Used in Connection with Random Digits," Monte Carlo Method (A. S. Householder, G. E. Forsythe, and H. H. Germond, eds.), National Bureau of Standards Applied Mathematics Series, 12, Washington, D.C.: U.S. Government Printing Office, 1951, pp. 36–38.
D. Knuth, The Art of Computer Programming, Volume 2: Seminumerical Algorithms, 3rd ed., Cambridge, MA: Addison-Wesley, 1997 pp. 1–193.