Post Reply 
New PRNG algorithm
12-21-2014, 10:34 PM (This post was last modified: 12-27-2014 02:52 PM by Namir.)
Post: #1
New PRNG algorithm
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
Find all posts by this user
Quote this message in a reply
12-26-2014, 01:22 AM
Post: #2
RE: New PRNG algorithm
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.
Find all posts by this user
Quote this message in a reply
Post Reply 




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