Xoroshiro128+
Main article: Xorshift#xoroshiro128+
xoroshiro128+ is a pseudorandom number generator intended as a successor to xorshift+. Instead of perpetuating Marsaglia's tradition of xorshift as a basic operation, xoroshiro128+ uses a shift/rotate-based linear transformation designed by Sebastiano Vigna in collaboration with David Blackman. The result is a significant improvement in speed and a significant improvement in statistical quality.
Statistical Quality
The authors of xoroshiro128+ acknowledge that it does not pass all statistical tests, statingThese claims about not passing tests can be confirmed by running PractRand on the input, resulting in output like that shown below:
/* This is xoroshiro128+ 1.0, our best and fastest small-state generator
for floating-point numbers. We suggest to use its upper bits for
floating-point generation, as it is slightly faster than
xoroshiro128**. It passes all tests we are aware of except for the four
lower bits, which might fail linearity tests, so if
low linear complexity is not considered an issue it can be used to generate 64-bit outputs, too; moreover, this
generator has a very mild Hamming-weight dependency making our test
fail after 5 TB of output; we believe
this slight bias cannot affect any application. If you are concerned,
use xoroshiro128** or xoshiro256+.
We suggest to use a sign test to extract a random Boolean value, and
right shifts to extract subsets of bits.
The state must be seeded so that it is not everywhere zero. If you have
a 64-bit seed, we suggest to seed a splitmix64 generator and use its
output to fill s.
NOTE: the parameters of this version give slightly
better results in our test than the 2016 version.
- /
RNG_test using PractRand version 0.93
RNG = RNG_stdin64, seed = 0xfac83126
test set = normal, folding = standard
rng=RNG_stdin64, seed=0xfac83126
length= 128 megabytes, time= 2.1 seconds
Test Name Raw Processed Evaluation
BRank:256 R= +3748 p~= 3e-1129 FAIL !!!!!!!!
BRank:384 R= +5405 p~= 3e-1628 FAIL !!!!!!!!
...and 146 test result without anomalies
Acknowledging the weak low order bit, the authors go on to say:
We suggest to use a sign test to extract a random Boolean value
Thus, programmers should prefer the highest bits. It must be noted, though, that the same test is failed by the Mersenne Twister, WELL, etc., so the issue is mainly of academic concern.
As stated in the comments, the generator fails a Hamming-weight dependency test developed by Blackman and Vigna after 8 TB of data. As a comparison, for some choice of parameters the Mersenne Twister at 607 bits fails the same test after less than a gigabyte of data.
Quotations
David Meister, who implemented it in Clojure, made some valuable statements:"This is a clojure implementation of the xoroshiro128+ PRNG described at http://xoroshiro.di.unimi.it. The algorithm has been shown to be fast and produce superior statistical results to many PRNGs shipped with languages, including Java. The statistical results have been verified in both PractRand and TestU01 by the authors. xoroshiro128+ is designed to be the successor to xorshift128+, currently used in the JavaScript engines of Chrome, Firefox and Safari. Both xorshift128+ and xoroshiro128+ have a period of 2128 but xoroshiro128+ is benchmarked by the authors as 20% faster and with 20% fewer failures in BigCrush than its predecessor."
Matt Gallagher, in his study on random number generators in Swift made the following conclusion:
It looks like Xoroshiro is the best general purpose algorithm currently available. Low memory, extremely high performance and very well distributed. Mersenne Twister might still be a better choice for highly conservative projects unwilling to switch to such a new algorithm, but the current generation of statistically tested algorithms brings a baseline of assurance from the outset that previous generations lacked.
Related generators
- xoroshiro128** prevents linear artifacts in the low bits
- xoshiro256+ has 256 bits of state allowing for more parallelism
- xoshiro256** — "our all-purpose, rock-solid generator"