Implementation
The Middle Square Method is a very simple, and very low quality, pseudo random number generator.
This generator works via a short series of steps:
- Take the current Seed and square it.
- Pad the resulting number with 0s until it is n*2 digits long.
- Take the middle n digits. This is both the new Seed and the returned random number.
Its creator, Br. Edwin, suggested that
n should be 4. That is the value used by this study, and this limits the generator to a range of 0 to 9999, inclusive. Changing the value of
n will greatly alter the generator's possible range and the likelihood of the generator falling into a loop. As it is, an
n value of 4 traps the generator in loops remarkably quickly, making it useable only as an example.
Test Results
SEED | Number indicates how many results could be obtained before the generator fell into a loop. |
1138 | 30 | FAIL |
65535 | 35 | FAIL |
8675309 | 26 | FAIL |
16777216 | 12 | FAIL |
123456789 | 18 | FAIL |
|
While this PRNG's very limited period causes it to fall into repeating patterns, its output is surprisingly well distributed, even if you consider that almost no 5s appeared. |
SEED | Minimum of 6,000 darts placed needed to pass. |
1138 | 15 | FAIL |
65535 | 17 | FAIL |
8675309 | 13 | FAIL |
16777216 | 6 | FAIL |
123456789 | 9 | FAIL |
SEED | 70% or higher required to pass. |
1138 | 1% | FAIL |
65535 | 1% | FAIL |
8675309 | 1% | FAIL |
16777216 | 1% | FAIL |
123456789 | 1% | FAIL |
|
Thanks to its very small period, this PRNG wasn't able to plot many points, and so fails the plot test by a large margin. |
2609 | 8068 | 926 | 8574 | 5134 | 3579 | 8092 | 4804 | 784 | 6146 | 7733 | 7992 | 8720 | 384 | 1474 | 1726 | 9790 | 8441 | 2504 | 2700 |
2900 | 4100 | 8100 | 6100 | 2100 | 4100 | 8100 | 6100 | 2100 | 4100 | 8100 | 6100 | 2100 | 4100 | 8100 | 6100 | 2100 | 4100 | 8100 | 6100 |
2100 | 4100 | 8100 | 6100 | 2100 | 4100 | 8100 | 6100 | 2100 | 4100 | 8100 | 6100 | 2100 | 4100 | 8100 | 6100 | 2100 | 4100 | 8100 | 6100 |
2100 | 4100 | 8100 | 6100 | 2100 | 4100 | 8100 | 6100 | 2100 | 4100 | 8100 | 6100 | 2100 | 4100 | 8100 | 6100 | 2100 | 4100 | 8100 | 6100 |
2100 | 4100 | 8100 | 6100 | 2100 | 4100 | 8100 | 6100 | 2100 | 4100 | 8100 | 6100 | 2100 | 4100 | 8100 | 6100 | 2100 | 4100 | 8100 | 6100 |
2100 | 4100 | 8100 | 6100 | 2100 | 4100 | 8100 | 6100 | 2100 | 4100 | 8100 | 6100 | 2100 | 4100 | 8100 | 6100 | 2100 | 4100 | 8100 | 6100 |
2100 | 4100 | 8100 | 6100 | 2100 | 4100 | 8100 | 6100 | 2100 | 4100 | 8100 | 6100 | 2100 | 4100 | 8100 | 6100 | 2100 | 4100 | 8100 | 6100 |
2100 | 4100 | 8100 | 6100 | 2100 | 4100 | 8100 | 6100 | 2100 | 4100 | 8100 | 6100 | 2100 | 4100 | 8100 | 6100 | 2100 | 4100 | 8100 | 6100 |
2100 | 4100 | 8100 | 6100 | 2100 | 4100 | 8100 | 6100 | 2100 | 4100 | 8100 | 6100 | 2100 | 4100 | 8100 | 6100 | 2100 | 4100 | 8100 | 6100 |
2100 | 4100 | 8100 | 6100 | 2100 | 4100 | 8100 | 6100 | 2100 | 4100 | 8100 | 6100 | 2100 | 4100 | 8100 | 6100 | 2100 | 4100 | 8100 | 6100 |
2100 | 4100 | 8100 | 6100 | 2100 | 4100 | 8100 | 6100 | 2100 | 4100 | 8100 | 6100 | 2100 | 4100 | 8100 | 6100 | 2100 | 4100 | 8100 | 6100 |
2100 | 4100 | 8100 | 6100 | 2100 | 4100 | 8100 | 6100 | 2100 | 4100 | 8100 | 6100 | 2100 | 4100 | 8100 | 6100 | 2100 | 4100 | 8100 | 6100 |
2100 | 4100 | 8100 | 6100 | 2100 | 4100 | 8100 | 6100 | 2100 | 4100 | 8100 | 6100 | 2100 | 4100 | 8100 | 6100 | 2100 | 4100 | 8100 | 6100 |
2100 | 4100 | 8100 | 6100 | 2100 | 4100 | 8100 | 6100 | 2100 | 4100 | 8100 | 6100 | 2100 | 4100 | 8100 | 6100 | 2100 | 4100 | 8100 | 6100 |
2100 | 4100 | 8100 | 6100 | 2100 | 4100 | 8100 | 6100 | 2100 | 4100 | 8100 | 6100 | 2100 | 4100 | 8100 | 6100 | 2100 | 4100 | 8100 | 6100 |
2100 | 4100 | 8100 | 6100 | 2100 | 4100 | 8100 | 6100 | 2100 | 4100 | 8100 | 6100 | 2100 | 4100 | 8100 | 6100 | 2100 | 4100 | 8100 | 6100 |
2100 | 4100 | 8100 | 6100 | 2100 | 4100 | 8100 | 6100 | 2100 | 4100 | 8100 | 6100 | 2100 | 4100 | 8100 | 6100 | 2100 | 4100 | 8100 | 6100 |
2100 | 4100 | 8100 | 6100 | 2100 | 4100 | 8100 | 6100 | 2100 | 4100 | 8100 | 6100 | 2100 | 4100 | 8100 | 6100 | 2100 | 4100 | 8100 | 6100 |
2100 | 4100 | 8100 | 6100 | 2100 | 4100 | 8100 | 6100 | 2100 | 4100 | 8100 | 6100 | 2100 | 4100 | 8100 | 6100 | 2100 | 4100 | 8100 | 6100 |
2100 | 4100 | 8100 | 6100 | 2100 | 4100 | 8100 | 6100 | 2100 | 4100 | 8100 | 6100 | 2100 | 4100 | 8100 | 6100 | 2100 | 4100 | 8100 | 6100 |