2.3 The middle-square-method
The middle-square-method was one of the first methods (John von Neumann, 1946) used to generate pseudo random numbers. The method works as follows. In order to generate the next number, square the current number and let the next number be the middle part of the product.Illustration: Let the base b=10, let the number of digits to consider n=2, and let the seed be 11. Squaring 11 gives 0121 and the middle part and the next number is thus 12. Proceeding in this way we obtain
X XX Recurrence graph 11 0121 11 -> 12 0144 12 -> 14 0196 14 -> 19 0361 19 -> 36 1296 36 -> 29 0841 29 -> 84 7056 84 -> 05 0025 05 -> 02 0004 02 -> 00 0000 00 -> 00 0000 00 .. ....This also illustrates one draw back of the method. Once zero is obtained all the following numbers are also zero. In real use we would of course use a larger n and hopefully get a large number of pseudo random numbers before the generator degenerates but the problem prevails. In other cases the generator ends up in a fairly short cycle.This is why this method was abandoned and other generators were considered.
As was stated in Section 2.1 pseudo random numbers should not be generated with a method chosen at random but according to some technique with analysable properties. A striking example of the opposite is given in Knuth where a "super-random technique" shows very bad performance.