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). right|250px|thumb|directed graph of all 100 2-digit pseudorandom numbers obtained using the middle-square method with n = 2. in mathematics, the middle-square method is a method of generating pseudorandom numbers. in practice it is not a good method, since its period is usually very short and it has some severe weaknesses, such as the output sequence almost always converging to zero. the method was first described in a manuscript by a franciscan friar (known only as brother edvin) sometime between 1240 and 1250. it was reinvented by john von neumann, and was notably described at a conference in 1949.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. to generate a sequence of 4-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 zeroes 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. for a generator of n-digit numbers, the period can be no longer than 8n. if the middle 4 digits are all zeroes, the generator then outputs zeroes forever. if the first half of a number in the sequence is zeroes, the subsequent numbers will be decreasing to zero. while these runs of zero are easy to detect, they occur too frequently for this method to be of practical use. the middle-squared method can also get stuck on a number other than zero. for n = 4, this occurs with the values 0100, 2500, 3792, and 7600. other seed values form very short repeating cycles, e.g., 0540 â 2916 â 5030 â 3009. these phenomena are even more obvious when n = 2, as none of the 100 possible seeds generates more than 14 iterations without reverting to 0, 10, 60, or a 24 â 57 loop. in the 1949 talk, von neumann famously quipped that, "any one who considers arithmetical methods of producing random digits is, of course, in a state of sin." what he meant, he elaborated, was that there were no true "random numbers", just means to produce them, and "a strict arithmetic procedure", like the one d
Pseudorandom_number_generators