[Coco] Is the RND command really generating a random number?

Melanie and John Mark Mobley johnmarkmelanie at gmail.com
Sat May 20 14:44:30 EDT 2017


100 rem **********
110 rem *** rnd ***
120 rem **********
140 rem multiple linear congruential random number generators
150 rem using a state machine
160 state=state+1
170 if state>=3 then state = 0
180 if state < 0 then state = 0
190 on state+1 goto 200, 300, 400
200 rem s1(n+1) = (s1(n) * a1 + b1) mod c1
210 x=s1*a1+b2
220 y=int(x/c1)
230 s1=x-(y*c1)
240 rnd = s1
250 goto 500
300 rem s2(n+1) = (s2(n) * a2 + b2) mod c2
310 x=s2*a2+b2
320 y=int(x/c2)
330 s2=x-(y*c2)
340 rnd = s2
350 goto 500
400 rem s3(n+1) = (s3(n) * a3 + b3) mod c3
410 x=s3*a3+b3
420 y=int(x/c3)
430 s3=x-(y*c3)
440 rnd =s3
440 goto 500
500 return

John Mark Mobley




More information about the Coco mailing list