(38G) Lagged Fibonacci PRNG
07-28-2015, 09:45 AM (This post was last modified: 06-15-2017 01:56 PM by Gene.)
Post: #1
 Gerald H Senior Member Posts: 1,522 Joined: May 2014
(38G) Lagged Fibonacci PRNG
For info on theory see:

https://en.wikipedia.org/wiki/Lagged_Fib..._generator

LFibSeeder seeds a vector of 127 random integers from 0 to M-1, M a positive integer given as input from Ans in the HOME screen.

Code:
 LFibSeeder Ans►M: MAKEMAT(INT(RANDOM*M),127,1)*[1]►M1:

LFibNext adds the 30th & 127th elements of the vector MODULO M, stores this value as the new first element of the vector, deletes the 128th element of the vector & returns new first element divided by M to Ans in the HOME screen.

Code:
 LFibNext ADDCOL M1;((M1(127) MOD -M)+M1(30)) MOD M;1: DELCOL M1;128: M1(1)/M:
 « Next Oldest | Next Newest »

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