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.


Concept

The basic formula for the Middle-Square Method is as follows:

  1. Multiply the seed value with itself (ie, square it).
  2. Pad the resulting number with 0s until the number has two more digits than your desired seed length.
  3. Save the middle digits as your new seed.
  4. Your new seed is the next random number.


Tested Variants



A WFTID Website