Computing Atlas

How Computing Was Built
Sign In
Text size
100%
Theme
Algorithm

Middle-square method

Numerical Algorithm

The middle-square method is an early way of generating pseudorandom numbers. To produce a sequence of n-digit numbers, one starts with an n-digit seed, squares it to get a number of up to 2n digits, pads with leading zeros if needed, and takes the middle n digits as the next number, then repeats. John von Neumann invented the method and described it at a conference in 1949. He joked that anyone using arithmetical methods to produce random digits is in a state of sin, but he found them hundreds of times faster than reading random numbers from punch cards, which mattered for his ENIAC work. In practice the method is badly flawed: its period is usually very short, the sequence can fall to zero or lock onto a repeating cycle, and with n digits the period cannot exceed 8 to the power n. Modifying it with a Weyl sequence improves period and randomness.

Connections

Credited To

Source Middle-square method (Wikipedia)

In Field

Source Middle-square method (Wikipedia)

Invented By

Source Middle-square method (Wikipedia)
Sources
Middle-square method (Wikipedia)
  • In Group: Statistical and Randomness Testing, Lead paragraph
    In mathematics and computer science, the middle-square method or midsquares method is a method of generating pseudorandom numbers.
  • In Field: Algorithms and Complexity Theory, Lead paragraph
    In mathematics and computer science, the middle-square method or midsquares method is a method of generating pseudorandom numbers.
  • Credited To: John von Neumann, History, In mathematics
    The method was invented by John von Neumann, and was described by him at a conference in 1949.
  • Invented By: John von Neumann, History, In mathematics
    The method was invented by John von Neumann, and was described by him at a conference in 1949.
View the Source
Comments (0)
No comments yet. Be the first to share a thought.
Reader Challenges (0)
No disputes yet. Spotted an error or a better source? Open the first one.