lua-users home
lua-l archive

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


On Mar 23, 2018, at 5:09 PM, Gé Weijers <ge@weijers.org> wrote:

I somehow misread the specs of this generator and interpreted it to mean that the period of the low-order bit was 128, not 2**128-1. 128 would be truly bad.

Period 2**128 - 1: Is it due to all zero state will never happen ?

2**128-1 is a long period, of course, but if you know the last 128 low-order bits you can predict the next one. This can be a problem in some applications.

You mean just two math.random(0) (128 bits) can predict the next one ?

If you only use one bit of each output value you may not want to use the bit with the worst statistical properties

Reading http://xoroshiro.di.unimi.it, it seems linearity is not that bad.
BUT, why Vigna say never use last 2 bits to build double ?  I am confused.

The linear dependencies causing the failure of the binary-rank test can be reduced by applying a nonlinear operation on the output: for example, multiplying by a constant, or adding as 64-bit integers (thus, in the ring Z/264Z) two pieces of the state space. This is what happens in the generators described here. With more operations it could be possible to completely eliminate the linear artifacts, but I consider this a waste of time: as we've seen, some of the most used generators around have linear dependencies in every bit, and this is not considered a problem. Note also that when generating floating point values you never use the two lowest bits.