Content deleted Content added
No edit summary |
No edit summary |
||
Line 1:
[[Image:Middle-square method.svg|right|250px|thumb|One iteration of the middle-square method, showing a six digit seed, which is then squared, and the resulting value has its middle six digits as the output value (and also as the next seed for the sequence).]]
In [[mathematics]], the '''middle-square method''' is a method of generating [[pseudorandom number]]s. In practice it is not a good method, since its period is usually very short and it has some crippling weaknesses, such as the output sequence always converging to zero. The method originated with [[John von Neumann]], and was notably described at a conference in 1949.<ref name="vonneumann">The 1949 papers were not reprinted until 1951. John von Neumann, “Various techniques used in connection with random digits,” in A.S. Householder, G.E. Forsythe, and H.H. Germond, eds., ''Monte Carlo Method, National Bureau of Standards Applied Mathematics Series'', vol. 12 (Washington, D.C.: U.S. Government Printing Office, 1951): pp. 36-38.</ref>
To generate a sequence of ten-digit pseudorandom numbers, a 4-digit starting value is created and squared, producing an 8-digit number (if the result is less than 8 digits, [[leading zero]]es are added to compensate). The middle 4 digits of the result would be the next number in the sequence, and returned as the result. This process is then repeated to generate more numbers.
|