The Museum of HP Calculators

HP Forum Archive 13

[ Return to Index | Top of Index ]

Random number generated on a 32sii
Message #1 Posted by Charles on 14 Sept 2003, 8:47 p.m.

Have any of you written a random number generating program for a 32sii? Specifically generating an integer between say 1 to 5? I don't have the manual and wonder if it could be already in existance?

Best regards, Charles

      
Re: Random number generated on a 32sii
Message #2 Posted by Robert on 14 Sept 2003, 10:22 p.m.,
in response to message #1 by Charles

It has a random number generator from 0 to 1(Prob -> R). Couldn't you just use a linear transform of that, i.e.,

Your Random Number = 1 + (4*R)

            
Re: Random number generated on a 32sii
Message #3 Posted by Patrick on 14 Sept 2003, 11:06 p.m.,
in response to message #2 by Robert

I think you would need to compute 1+int(5*R) to get a random integer in the range 1..5. Most random number generators produce fractions from zero to one, including zero but not including one.

      
1+IP(RANDOM*5 [CK=A6CC 10.5byte] (NO TEXT, just a 'dot')
Message #4 Posted by Tizedes Csaba on 15 Sept 2003, 3:46 a.m.,
in response to message #1 by Charles

.

      
With a little program
Message #5 Posted by Tizedes Csaba on 15 Sept 2003, 4:44 a.m.,
in response to message #1 by Charles

Hi!

Try it:

LBL R        #random
INPUT N      #how many Nums?
INPUT I      #mInimum?
INPUT A      #mAximum?
LBL J        #jump here
RCL A
RCL sub I
1
add
RANDOM
mul
IP
RCL add I
PSE         #put another PSE, if it too fast
DSE N
GTO J
RTN

'add', 'sub', 'mul', 'div' mean 'add', 'substract', 'multiple' and 'divide' in this order.

Csaba


[ Return to Index | Top of Index ]

Go back to the main exhibit hall