HP41C random number generator help

12062017, 03:03 AM
Post: #21




RE: HP41C random number generator help
This (rn = new seed = 9821 · previous seed + 0,211327 )typealsoPPCROMdoneitthatway here as MCode, for the connoisseurs
Code: * HP41 Random Number in MCode 

12082017, 04:26 AM
(This post was last modified: 12082017 04:33 AM by Trond.)
Post: #22




RE: HP41C random number generator help
(12052017 12:30 PM)Namir Wrote: A good and simple algorithm (used by HP since the HP65 Stat Pacs) is:I tried a version of this while trying to avoid "bad seeds". I built a program that first checks if the variable 00 has anything above 0 beyond the fifth decimal point, and if not it adds pi, then goes on to multiply with 997, does FRC and STO 00. If 00 does have a digit at the fifth decimal it will simply do the last three steps. Looks to work fine for me, but it is no longer as simple of course. 

12082017, 07:43 PM
Post: #23




RE: HP41C random number generator help
(12082017 04:26 AM)Trond Wrote: I tried a version of this while trying to avoid "bad seeds". I built a program that first checks if the variable 00 has anything above 0 beyond the fifth decimal point, and if not it adds pi, then goes on to multiply with 997, does FRC and STO 00. If 00 does have a digit at the fifth decimal it will simply do the last three steps. Looks to work fine for me, but it is no longer as simple of course. Why don't you simply do it ...right? There is a clear definition of the minimal properties that have to be met: seven decimals, and the last one must be 1, 3, 7 or 9. This can be done with the following SEED code: Code: LBL"SEED" Enter a seed, XEQ "SEED", and if neccessary the input is corrected. Example: pi => 0,1415923 Yes, this simply sets the 7th decimal to 3 even if it was another valid digit like 1, 7 or 9 before. ;) Dieter 

12082017, 09:17 PM
(This post was last modified: 12082017 09:18 PM by Trond.)
Post: #24




RE: HP41C random number generator help
(12082017 07:43 PM)Dieter Wrote: Why don't you simply do it ...right? There is a clear definition of the minimal properties that have to be met: seven decimals, and the last one must be 1, 3, 7 or 9. This can be done with the following SEED code: I guess I missed the 1, 3, 7, 9 part, but yes I meant beyond the sixth decimal (do we have this written down somewhere? You seemed uncertain too). I was thinking not to change the seed if it's not necessary, but well, not sure how often it matters. But I also wanted to replace seeds that always predictably produce numbers that start with 0 in the first few decimals. Very small seeds will always start up with 0 in their first few decimals, and this includes the seed 0.0000003 which will be common (since the variable having a 0 stored is common). Having said that, my other random number generator program is working fine so, no big issue there. It was just a bit fascinating with the simplicity of multiplying with one number. 

12082017, 09:56 PM
(This post was last modified: 12082017 10:04 PM by Dieter.)
Post: #25




RE: HP41C random number generator help
(12082017 09:17 PM)Trond Wrote: I guess I missed the 1, 3, 7, 9 part, but yes I meant beyond the sixth decimal (do we have this written down somewhere? You seemed uncertain too). As already noted, an article in PPC Journal V4N8 by Victor K. Heyman takes a close look at four popular PRNGs, among them the 997x generator. The article mentions 11 different tests, even some quite sophisticated ones. Here it says: Quote:With the proper seed, this generator has a cylce of 500,000 iterations. HP chose pretty well when it selected .5284163. It is supposed to pass all standard tests, and with a blink or two, it does. That is a tough seed to remember, and worse to program, so I have found one that is as good and much easier on the user: Pi, Sin, Tan. It works, and also follows all the rules  the seed must have seven digits after multiplying by 997, the 7th not divisible by 2 or 5. (...) However every seed that meets the rule is not good. "Not divisible by 2 or 5" means 1, 3, 7 or 9 for the seed's last digit. And that's exactly what the 997x generator produces. Dieter 

12092017, 09:53 PM
Post: #26




RE: HP41C random number generator help
(12082017 07:43 PM)Dieter Wrote: Yes, this simply sets the 7th decimal to 3 even if it was another valid digit like 1, 7 or 9 before. ;) OKOK, here is a version that adjust the input only when required. Code: LBL "SEED997" Example: 0,1234567 XEQ"SEED997" => 0,1234567 0,2222222 XEQ"SEED997" => 0,2222223 Dieter 

12102017, 04:09 AM
Post: #27




RE: HP41C random number generator help
(12092017 09:53 PM)Dieter Wrote:(12082017 07:43 PM)Dieter Wrote: Yes, this simply sets the 7th decimal to 3 even if it was another valid digit like 1, 7 or 9 before. ;) Taking things as a challenge is a good thing! OK I will try this one. 

« Next Oldest  Next Newest »

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