User:JCatCPCW/sandbox

Recent Developments
In the book "Random Numbers and Computers”, Kneusel states the following:

“Interestingly, recently (as of 2017) the middle square method has resurfaced. In "Middle Square Weyl Sequence RNG" Widynski proposes a straightforward modification of the middle square algorithm which results in a very fast generator with a respectable period, excellent results in randomness tests, and easy application in parallel”.

A Weyl sequence is used to run the middle square. The Weyl sequence provides uniformity and a known minimum period; the middle square provides randomization. The combined generator passes very stringent tests of randomness including the BigCrush and PractRand tests. Many commonly used RNGs do not pass these tests.

A C language implementation is shown below.

A counter-based version was published in 2020, “Squares: A Fast Counter-Based RNG”. Counter-based RNGs are well suited to parallel processing. Four rounds of squaring are applied to a counter to produce a random output. Squares may be the fastest RNG in this category. The squares generator is shown below.