lua-users home
lua-l archive

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




On Fri, Mar 23, 2018 at 9:42 AM, albertmcchan <albertmcchan@yahoo.com> wrote:

What is linearity ?

Does linearity affect randomness (make it predictable) ?




"Linear" here means you can describe it easily using linear algebra. A single step of this random number generator can be described as the application of a 128 x 128 boolean matrix on the state. It's a non-singular matrix, so you can invert it, and run the RNG backwards, and do all kinds of nifty tricks with it like calculating any value in the sequence quickly, without calculating any of the preceding values.

It is fairly simple to predict the next output value if you know the last few output values of this generator or generators like it. So you don't want to use a generator like this for casino games or anything else that has security requirements, unless you use measures to protect yourself. If you don't:

  https://www.wired.com/2017/02/russians-engineer-brilliant-slot-machine-cheat-casinos-no-fix/

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. 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. If you only use one bit of each output value you may not want to use the bit with the worst statistical properties.