Shinmera / random-state

A collection of portable random generators for Common Lisp
http://shinmera.github.io/random-state/
zlib License
27 stars 9 forks source link

Xorshift variant support #28

Closed gingeralesy closed 1 year ago

gingeralesy commented 1 year ago

Support for various variants of Xorshift pseudo-random generator.

For execution in software, xorshift generators are among the fastest PRNGs, requiring very small code and state. However, they do not pass every statistical test without further refinement. This weakness is amended by combining them with a non-linear function, as described in the original paper. Because plain xorshift generators (without a non-linear step) fail some statistical tests, they have been accused of being unreliable. — https://en.wikipedia.org/wiki/Xorshift

This PR includes both linear and non-linear variants of the generators. I have also tested them all to work faster than their matching (random) call. The wikipedia page further lists pros and cons of the generator.

Inspired by 2015 article on Math.random(), https://v8.dev/blog/math-random Based on works of George Marsaglia (https://www.jstatsoft.org/article/view/v008i14) and Sebastiano Vigna (https://prng.di.unimi.it/).

Shinmera commented 1 year ago

Looks good, thanks a lot!