Details
This is the updated Middle-Square Method, created by Bernard Widynski in 2017. As we did for the original version, we are going to use the middle six digits of the seed.
Adding a Weyl Sequence clearly improved the quality of this type of PRNG, though it still suffers from a very short period and, as the plot results show, the output isn't very random compared to newer generators. It does, however, pass many of our tests.
|
Pseudocode
// The current state value
state = 1138;
// Values used for the Weyl Sequence
s = $b5ad4eceda1ce2a9;
w = 0;
// random number generator
function RandomNumber() {
// Multiply the state by itself
tmp = state * state;
// Add the Weyl Sequence
w = w + s;
tmp = tmp + w;
// Add enough padding to make it at least 8 digits
tmp.pad_left('0', 8);
// Save the middle 6 digits
state = tmp.substr( (tmp.length / 2) - 3 , 6 );
// Return the new value
return state;
}
|
Period Length TestSeed | Period Length | Result |
---|
1138 | 1033 | Failed | 65535 | 1580 | Failed | 8675309 | 1531 | Failed | 16777216 | 2035 | Failed | 123456789 | 2121 | Failed | Minimum to Pass: 64,000
| Plot Test  |
Count the 1s TestSeed | % Bits that are 1s | Result |
---|
1138 | 49.55% | Passed | 65535 | 49.21% | Passed | 8675309 | 49.32% | Passed | 16777216 | 49.51% | Passed | 123456789 | 49.51% | Passed | Minimum to Pass: 45%
| Dartboard TestSeed | Darts Placed | Result |
---|
1138 | 1420 | Failed | 65535 | 1478 | Failed | 8675309 | 1530 | Failed | 16777216 | 1390 | Failed | 123456789 | 1457 | Failed | Minimum to Pass: 2,600
|
Crush TestSeed | Compression Rate | Result |
---|
1138 | 101.14% | Passed | 65535 | 101.14% | Passed | 8675309 | 101.14% | Passed | 16777216 | 101.14% | Passed | 123456789 | 101.14% | Passed | Minimum to Pass: 95%
| Unique Bytes TestSeed | Unique High Bytes | Unique Low Bytes | Result |
---|
1138 | 172 | 158 | Failed | 65535 | 166 | 163 | Passed | 8675309 | 168 | 168 | Passed | 16777216 | 164 | 170 | Passed | 123456789 | 172 | 151 | Failed | Minimum to Pass: 160
|
High/Low Byte TestSeed | High After High | High After Low | Low After High | Low After Low | Spread | Result |
---|
1138 | 2070 | 2904 | 2903 | 2122 | 1615 | Failed | 65535 | 2099 | 2884 | 2885 | 2131 | 1539 | Failed | 8675309 | 2070 | 2904 | 2904 | 2121 | 1617 | Failed | 16777216 | 2070 | 2904 | 2904 | 2121 | 1617 | Failed | 123456789 | 2076 | 2899 | 2899 | 2125 | 1597 | Failed | Maximum to Pass: 500
|
Distribution TestSeed | 1138 | 65535 | 8675309 | 16777216 | 123456789 |
---|
0.0 to 0.1 | 1018 | 1017 | 1019 | 1015 | 1003 |
---|
0.1 to 0.2 | 991 | 993 | 986 | 990 | 1001 |
---|
0.2 to 0.3 | 994 | 991 | 1006 | 1000 | 983 |
---|
0.3 to 0.4 | 991 | 987 | 978 | 983 | 1005 |
---|
0.4 to 0.5 | 985 | 993 | 991 | 988 | 985 |
---|
0.5 to 0.6 | 985 | 990 | 992 | 979 | 976 |
---|
0.6 to 0.7 | 1059 | 1053 | 1055 | 1065 | 1070 |
---|
0.7 to 0.8 | 993 | 996 | 995 | 997 | 989 |
---|
0.8 to 0.9 | 998 | 996 | 986 | 990 | 992 |
---|
0.9 to 1.0 | 987 | 985 | 993 | 994 | 997 |
---|
Spread | 153 | 139 | 159 | 159 | 157 |
---|
Result | Passed | Passed | Passed | Passed | Passed |
---|
Maximum to Pass: 500 |
Sample Output792656 | 669013 | 730628 | 354175 | 972776 | 44406 | 657647 | 284637 | 38071 | 966433 | 598443 | 215369 | 275673 | 898653 | 528654 | 586794 | 210128 | 829810 | 458939 | 517581 | 140838 | 761043 | 830058 | 453840 | 71695 | 692371 | 760535 | 384210 | 2586 | 64532 | 687258 | 314624 | 933575 | 4723 | 618692 | 245204 | 305399 | 928415 | 558787 | 759746 | 242045 | 859544 | 489031 | 547456 | 170746 | 790725 | 860107 | 483937 | 101566 | 722012 | 790543 | 414264 | 32415 | 94132 | 716894 | 344629 | 963362 | 34877 | 648293 | 275168 | 335144 | 958195 | 588938 | 205909 | 266286 | 889256 | 519139 | 577348 | 200671 | 820425 | 494383 | 508573 | 131400 | 751670 | 820569 | 444337 | 62263 | 123749 | 746548 | 374653 | 993167 | 65049 | 677912 | 305150 | 364907 | 987992 | 619107 | 235863 | 296008 | 919012 | 549266 | 607259 | 230614 | 850143 | 479523 | 538017 | 161297 | 781347 | 850613 | 474428 |
|