Good news for PPC Random-Number Generator
05-17-2021, 11:35 PM
Post: #7
 Albert Chan Senior Member Posts: 1,800 Joined: Jul 2018
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.
 « Next Oldest | Next Newest »

 Messages In This Thread Good news for PPC Random-Number Generator - Namir - 05-17-2021, 07:51 PM RE: Good news for PPC Random-Number Generator - Gene - 05-17-2021, 09:01 PM RE: Good news for PPC Random-Number Generator - Namir - 05-17-2021, 09:19 PM RE: Good news for PPC Random-Number Generator - Sylvain Cote - 05-17-2021, 11:03 PM RE: Good news for PPC Random-Number Generator - Massimo Gnerucci - 05-18-2021, 06:02 AM RE: Good news for PPC Random-Number Generator - Thomas Okken - 05-19-2021, 03:18 PM RE: Good news for PPC Random-Number Generator - Dave Britten - 05-17-2021, 10:56 PM RE: Good news for PPC Random-Number Generator - Namir - 05-18-2021, 03:13 AM RE: Good news for PPC Random-Number Generator - Craig Bladow - 05-17-2021, 11:03 PM RE: Good news for PPC Random-Number Generator - Albert Chan - 05-17-2021 11:35 PM RE: Good news for PPC Random-Number Generator - Namir - 05-18-2021, 03:15 AM RE: Good news for PPC Random-Number Generator - Craig Bladow - 05-19-2021, 01:48 AM RE: Good news for PPC Random-Number Generator - Namir - 05-19-2021, 03:29 AM RE: Good news for PPC Random-Number Generator - Craig Bladow - 05-19-2021, 01:20 PM RE: Good news for PPC Random-Number Generator - Valentin Albillo - 05-19-2021, 03:23 PM RE: Good news for PPC Random-Number Generator - Valentin Albillo - 05-19-2021, 02:18 AM RE: Good news for PPC Random-Number Generator - Valentin Albillo - 05-17-2021, 11:50 PM RE: Good news for PPC Random-Number Generator - Namir - 05-18-2021, 10:35 AM RE: Good news for PPC Random-Number Generator - rprosperi - 05-19-2021, 05:41 PM RE: Good news for PPC Random-Number Generator - Valentin Albillo - 05-19-2021, 06:31 PM RE: Good news for PPC Random-Number Generator - Thomas Okken - 05-19-2021, 10:04 PM RE: Good news for PPC Random-Number Generator - Albert Chan - 05-19-2021, 11:53 PM RE: Good news for PPC Random-Number Generator - rprosperi - 05-20-2021, 12:49 AM

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