lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Mar 15, 2018, at 7:50 PM, Luiz Henrique de Figueiredo <lhf@tecgraf.puc-rio.br> wrote:

>> is math.random uses xorshift128+ algorithm ?
>> 
>> why is the code different from https://en.m.wikipedia.org/wiki/Xorshift ?
> 
> See these:
> http://xoroshiro.di.unimi.it
> http://xoroshiro.di.unimi.it/xorshift128plus.c
> https://stackoverflow.com/questions/34426499/what-is-the-real-definition-of-the-xorshift128-algorithm
> 

thanks.

from the c source code comments, it seems the low bits is not
as good as the high bits.  You might consider using the top bits to
build the double value (math.random() is using low bits via maskFIG)

this is a quote from above xorshift128plus.c:

We suggest to use a sign test to extract a random boolean value,
and right shifts to extract subsets of bits.