Random number generator in HP 30S

02192017, 08:02 AM
(This post was last modified: 02192017 08:04 AM by Joe Horn.)
Post: #1




Random number generator in HP 30S
Anybody know which pseudorandom number generator is used in the HP 30S? It seems to be a very poor generator, since RANDM*2^16 always returns integers (that's sad) which alternate between even and odd (also sad). The 30S doesn't let you seed the generator; even clearing the calculator doesn't restart the generator at a predictable place in its sequence. Any insights that you have about the 30S's random number generator would be greatly appreciated.
<0ɸ0> Joe 

02192017, 01:03 PM
Post: #2




RE: Random number generator in HP 30S
I can only confirm no way to seed RANDM.


02192017, 03:06 PM
Post: #3




RE: Random number generator in HP 30S
(02192017 08:02 AM)Joe Horn Wrote: Any insights that you have about the 30S's random number generator would be greatly appreciated. The attached Learning Module from HP confirms the seed is taken from the internal clock, and while otherwise does not seem to explain the algorithm, could provide insights. I'll leave the attachment up for a few days... Bob Prosperi 

02192017, 09:32 PM
Post: #4




RE: Random number generator in HP 30S
Thanks, Bob. It would therefore seem that nobody knows what the 30S's pseudorandom number generator is. However, is there a way (without being John Nash) to take the integer sequence generated by RANDM*2^16 and find that sequence's generator?
Meanwhile, it should probably be noted somewhere that the RANDM function in the HP 30S should NOT be used for anything that requires a large cycle. RANDM only outputs 65536 different values. Therefore using it, for example, to pick a winning sweepstakes ticket number between 1 and 1 million would be grossly unfair, since over 93% of those ticket numbers would have zero probability of being picked. Strange that RANDM*65536 generates integers that alternate between even and odd, whereas RANDMI(0,65535) does not. <0ɸ0> Joe 

02192017, 10:22 PM
Post: #5




RE: Random number generator in HP 30S
It is possible that there is more going on behind the scenes and that the period is greater than 2^{16}. Still, alternating odd/even is pretty bad.
 Pauli 

02202017, 09:14 PM
Post: #6




RE: Random number generator in HP 30S
The alternating oddeven behavior might indicate a linear congruential generator with 2^16 modulus. If you can look at the output in binary, a clue would be that the lowest order bit alternates; the second lowest bit has a cycle of 4; the third order has a cycle of 8, etc. For a cycle of length 2^16, there are algorithms that can determine the parameters; Google can probably find them.


02202017, 10:23 PM
Post: #7




RE: Random number generator in HP 30S
(02202017 09:14 PM)ttw Wrote: The alternating oddeven behavior might indicate a linear congruential generator with 2^16 modulus. That's what I strongly suspect. (02202017 09:14 PM)ttw Wrote: If you can look at the output in binary, a clue would be that the lowest order bit alternates; the second lowest bit has a cycle of 4; the third order has a cycle of 8, etc. Aha! You're right! Sequential executions of RANDM*2^16, converted to binary, always exhibit the behavior you describe, but only the last 3 bits. All the higherorder bits seem random. (02202017 09:14 PM)ttw Wrote: For a cycle of length 2^16, there are algorithms that can determine the parameters; Google can probably find them. Time to go hunting! This is exciting! <0ɸ0> Joe 

« Next Oldest  Next Newest »

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