Random: Xorshift-16

The last generator tested is a 16 bit Xorshift.  With such a short cycle length (64K) a 16 bit generator is not expected to perform well on any meaningful statistical tests like dieharder and this generator does not disappoint.  It consistently fails every dieharder test!

However, it does perform well on the ent tests.  Obviously, it is extremely fast and very small making it a good candidate for the Tiny Core.


Xorshift-16 adds 34 bytes to the image which is significantly less than all the other generators.


On a 1 MHz ATtiny85 processor Xorshift-16 takes 0.044 milliseconds (44 microseconds) to generate the next value which is more the 44 times (!) faster than the Libc random function and significantly faster than all the other generators.


Xorshift-16 consistently fails all the dieharder tests.  It performs well on the ent tests.


Valid seeds are in the range 1 to 216-1 (0xFFFF).  Zero is the only bad seed and is fatal.



Matches Delphi.

Leave a Reply