lua-users home
lua-l archive

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


On Mar 26, 2018, at 11:34 AM, Coda Highland <chighland@gmail.com> wrote:

On Mar 26, 2018 9:38 AM, "albertmcchan" <albertmcchan@yahoo.com> wrote:

I tried print out 128 last bits (128 math.random calls), but I do not
see the pattern.  How does the prediction work ?

You can try it on lua 5.4.0-work1

function last128()
    for i=1,128 do io.write(math.random(0) & 1) end
end


It's not trivial. There's not a visible pattern but you can do math to reverse-engineer the internal state with that data. I don't know the technique myself.

/s/ Adam

If what you are saying is true, period of last128() is also 2^128 - 1, all unique.

Each last128() map 1-to-1 to 2^128 - 1 internal states.

one last128() pattern will never occurs. (all zeroes ?)