10176

# John von Neumann's First Pseudorandom Number Generator

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.
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."

### DETAILS

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.

### PERMANENT CITATION

 Share: Embed Interactive Demonstration New! Just copy and paste this snippet of JavaScript code into your website or blog to put the live Demonstration on your site. More details » Download Demonstration as CDF » Download Author Code »(preview ») Files require Wolfram CDF Player or Mathematica.

#### Related Topics

 RELATED RESOURCES
 The #1 tool for creating Demonstrations and anything technical. Explore anything with the first computational knowledge engine. The web's most extensive mathematics resource. An app for every course—right in the palm of your hand. Read our views on math,science, and technology. The format that makes Demonstrations (and any information) easy to share and interact with. Programs & resources for educators, schools & students. Join the initiative for modernizing math education. Walk through homework problems one step at a time, with hints to help along the way. Unlimited random practice problems and answers with built-in Step-by-step solutions. Practice online or make a printable study sheet. Knowledge-based programming for everyone.