About the Middle-Square Method
History
The Middle Square Method may be the oldest known Pseudo-Random Number Generator. According to legend, it was created sometime between 1240 and 1250 AD by a Franciscan friar known as Br. Edwin. Unsatisfied with how a skilled person could manipulate a dice throw, he designed the Middle-Square method as an impartial way to produce a seemingly random number. His idea was for each party to come up with a number, then pass their numbers through a simple series of transformations, with the result being their "dice roll".
Whether or not this story is true, the Middle-Square Method was brought up again by John von Neumann during a confrerence in 1949. This has led to von Neumann being credited with the creation of the Middle-Square Method.
In 2017, Bernard Widynski published a revision of the Middle-Square Method that adds a simple Weyl Sequence to the generator. This results in a larger period with more random results.
Whether or not this story is true, the Middle-Square Method was brought up again by John von Neumann during a confrerence in 1949. This has led to von Neumann being credited with the creation of the Middle-Square Method.
In 2017, Bernard Widynski published a revision of the Middle-Square Method that adds a simple Weyl Sequence to the generator. This results in a larger period with more random results.
Concept
The basic formula for the Middle-Square Method is as follows:
- Multiply the seed value with itself (ie, square it).
- Pad the resulting number with 0s until the number has two more digits than your desired seed length.
- Save the middle digits as your new seed.
- Your new seed is the next random number.
Tested Variants
- Middle-Square Method
The original design, as described by John von Neumann. - Middle-Square /w Weyl Sequence
Bernard Widynski's revised design, using his recommended constants.