New PRNG algorithm - Printable Version +- HP Forums (https://www.hpmuseum.org/forum) +-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html) +--- Forum: General Forum (/forum-4.html) +--- Thread: New PRNG algorithm (/thread-2686.html) New PRNG algorithm - Namir - 12-21-2014 10:34 PM One of the simple Pseudo Random Number Generators (PRNG) that I saw in HP-65 software manuals is: r1 = frac(r0 * 997) where r0 is the current random number, and r1 is the new one. It is simple and quite good. Recently I saw a similar variant: r1 = frac(r0 * 147) That got me curious. Since I was already doing a study on PRNGs (running several machines 24/7 to crunch random numbers using different variants of an algorithm), I decided to take a small detour and study a selection of numbers between 100 and 1000 (all ending in 7) that can do a better job than the version using the multiplier 997. I am happy to report that the following two PRNGs do well: r1 = frac(r0 * 127) and r1 = frac(r0 * 577) While the version with the 127 multiplier is better than the one with the 557 multiplier, it sometimes hiccups and generates sequences that are slightly more auto-correlated. Namir RE: New PRNG algorithm - ttw - 12-26-2014 01:22 AM For any of these Linear Congruential Generators, a good rule of thumb is to compute the sum of partial quotients of the multiplier and the modulus. A low sum implies low serial correlation. Cf. the Wiki on LCGs.