lua-users home
lua-l archive

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




On Mon, Mar 26, 2018 at 10:01 AM, albertmcchan <albertmcchan@yahoo.com> wrote:
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 ?)



The period of the RNG cannot be more than 2^128, because the state is only 128 bits. The state is updated using a function that maps the zero state to the zero state, and any non-zero state to a non-zero state, so the maximal possible period is 2^128-1, assuming you don't seed it with all-zero bits (which the Lua seed algorithm avoids).

This type of RNG is explained here:

https://en.wikipedia.org/wiki/Xorshift


--
--