lua-users home
lua-l archive

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


128 math.random(0) last bit can actually predict the sequence,
not just the last bit

let c = last bit LSFR coefficients = (c1, c2, ..., c128)
let x = last bit of 128 math.random(0) = (x1, x2, ... x128)

x129 = (c . x) & 1    -- predict last bit using vector dot product

Within the full period 2^128 - 1, all x's are unique
(otherwise, last bit period will be LESS than 2^128 - 1)

But, xorshift128+ only have 2^128 - 1 possible seeds
-> x and seed must map 1-to-1
-> x (after solving the seed) can predict the sequence.