Post Reply 
HP 12C Random Integer Number Generator
11-16-2017, 08:06 AM
Post: #2
RE: HP 12C Random Integer Number Generator
(11-16-2017 04:58 AM)Gamo Wrote:  Is there any better or shorter solution for this kind of random program?

This generator r:=frac(997*r) was quite popular in the Seventies as it was fast and short and provided good results. However, some care about the initial seed was required, so some implementations (including yours) set this seed within the program. Which means that the produced number sequence is not random, but the same each time you restart the program.

Another well-reputed RNG that was often used in HP programs is r:=frac(9821*r+0,211327). This one is less picky about the initial seed. Simply enter anything between 0 and 1 in R0 and run the program.

For many purposes even simpler generators may do. For instance r:=frac[(r+pi)²]. I often used this one in games programs and I had no problems with the results.

There was an extensive thread on RNGs last year, related to an translation of HP67 games for the HP41. You will find more information there, including articles in HP-related papers, discussing different generators. The one mentioned above turned out to be a good choice.

Dieter
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: HP 12C Random Integer Number Generator - Dieter - 11-16-2017 08:06 AM



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