Post Reply 
Good news for PPC Random-Number Generator
05-17-2021, 11:35 PM
Post: #7
RE: Good news for PPC Random-Number Generator
(05-17-2021 11:03 PM)Craig Bladow Wrote:  Matlab uses double precision floating point by default, does the algorithm still pass if limited to single precision or HP-41 precision?

Algorithm is really LCG, disguised as floating points.

Example, we can rewrite it this way (initial seed in units of millionth)

Code:
function make_rnd(seed)
    return function()
        seed = (seed*9821 + 211327) % 1000000
        return seed / 1000000
    end
end

lua> rnd = make_rnd(123456) -- seed 0.123456
lua> rnd(), rnd(), rnd(), rnd(), rnd()
0.672703       0.82749       0.990617       0.060884       0.153091

Seed calculations are integer based, without rounding errors.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Good news for PPC Random-Number Generator - Albert Chan - 05-17-2021 11:35 PM



User(s) browsing this thread: 1 Guest(s)