# Xorshift

These are discovered by George Marsaglia. I had to investigate these during my time at Ericsson.

For execution in software, xorshift generators are among the fastest non-cryptographically-secure random number generators, requiring very small code and state.

However, they do not pass every statistical test without further refinement.

We fix this weakness by combining them with a non-linear function, resulting e.g. in an xorshift+ or xorshift* generator.

A xorshift* generator takes a xorshift generator and applies an invertible multiplication (modulo the word size) to its output as a non-linear transformation

Xorshift+, rather than using multiplication, it is possible to use addition as a faster non-linear transformation. The implementation, however, is with 128bits, so there is extra memory requirements.

### Scrambers (+, *, ++, **)

Scramblers are nonlinear mappings from the state of the linear engine to a 𝑤-bit value, which will be the output of the generator.

Scramblers improve the quality of the raw output of the linear engine: since in general linear transformations have several useful provable properties, this is a practical approach to obtain a fast, high-quality generator.

### Xoshiro

https://vigna.di.unimi.it/ftp/papers/ScrambledLinear.pdf

https://prng.di.unimi.it/ <- Link to code

**xoshiro** and **xoroshiro** are other variations of the shift-register generators, using rotations in addition to shifts. According to Vigna, they are faster and produce better quality output than xorshift.

There are several variations.

Floating-Number Generation
**Xoroshiro128+** is the best and fastest small-state generator for floating-point numbers. However, for floating point outputs (use the + variant),take the upper 53 bits (for binary64) or the upper 23 bits (for binary32), since the upper bits are of better quality than the lower bits in the floating point generators.