Does anybody know a better way than
Code: Select all
01 LBL "RNDM"
02 DATE
03 TIME
04 *
05 SEED
06 RAN
07 RTN
Thinking about it, maybe
Code: Select all
01 LBL "RNDM"
02 DATE
03 TIME
04 *
05 TAN
06 ABS
07 1
08 MOD
09 RTN
Code: Select all
01 LBL "RNDM"
02 DATE
03 TIME
04 *
05 SEED
06 RAN
07 RTN
Code: Select all
01 LBL "RNDM"
02 DATE
03 TIME
04 *
05 TAN
06 ABS
07 1
08 MOD
09 RTN
It doesn't seem to work on DM42 with current (V3.3) firmware at least. 0 SEED RAN RAN RAN produces the same sequence each time.Thomas Okken wrote: ↑Wed Feb 14, 2018 11:39 amJust use 0 SEED. That seeds the random number generator using the real-time clock.
How exactly it does this depends on how the shell_random_seed() function is implemented, and that is part of the platform-specific code, so we don't know (yet) how this works on the DM42.
It's possible that they didn't notice the API change in 2.0.7, when shell_random_seed() changed from returning a double in the range [0, 1) to returning a 64-bit int. Assuming that doesn't cause a compilation failure outright, I could see it seeding the sequence with 0 every time.ijabbott wrote: ↑Wed Feb 14, 2018 5:09 pmIt doesn't seem to work on DM42 with current (V3.3) firmware at least. 0 SEED RAN RAN RAN produces the same sequence each time.Thomas Okken wrote: ↑Wed Feb 14, 2018 11:39 amJust use 0 SEED. That seeds the random number generator using the real-time clock.
How exactly it does this depends on how the shell_random_seed() function is implemented, and that is part of the platform-specific code, so we don't know (yet) how this works on the DM42.
Krauts In Space wrote: ↑Thu Feb 15, 2018 8:59 amI don't have time nor I'm a mathematican with a "Random" Degree but this looks strange to me.
It uses the same algorithm as the real HP-42S, which is the same as the RPL calculators, except for using a different starting seed after Memory Clear.
Has the SEEDing on the DM42 prior to 2.0.7 ever been tested?Thomas Okken wrote: ↑Sat Feb 17, 2018 4:56 pmIt uses the same algorithm as the real HP-42S, which is the same as the RPL calculators, except for using a different starting seed after Memory Clear.
I implemented this in 2.0.7 (DM42 3.1); earlier versions used the RNG from the HP-41C applications book: r[n+1] = frac(r[n]*9821+0.211327).
The RPL/42S algorithm, and the way RDZ/SEED work, are explained in agonizing detail here: https://groups.google.com/forum/m/#!msg ... tzMtZhlGoJ.