Re: A92: random number
[Prev][Next][Index][Thread]
Re: A92: random number
Me again. Thank you for your algorithm, but something
doesn't work. As you said, for example, let's take c=1993, m=12893,
z0=17.
z1 = (1993*17) mod 12893 =
8095 all right
!
but z2 = (1993*8095) mod 12893 = 4192
and not 8695
!
Surely have I not understood. In fact, is it z1 = (c * z0) mod m
or z1 = c * (z0 mod m) ?
_____________________________________________________________________
Robert Caldwell schrieb:
>
>
{{Thank you for your help, but I didn't mean that exactly. I wanted to
> know an
> algorithm to generate random numbers, for example
with a pen and a sheet
> of
> paper, and then how to code this
algorithm in assembly for Fargo. Thanx.
>
MP}}
>
>
>
> I have the formulas to calculate the
two seed numbers, but I could never
> figure out how to get from the
2 seed numbers to the random number. So,
> if anyone knows how
to do this I would appreciate the algorithm, also.
Take two integers
c and m both positive and a third one: z0. Get z1 = c*z0 mod m
and so on
replacing z0 by z1 by z2.... zi/m can be used as a pseudo random
number
between 0 and 1, taken from "Taschenbuch der Mathematik",
Bronstein,
Semendjajew
if you take c= 1993 , m=12893 ,z0=17 you get
z1=8095(rand:0.62786), z2=8685...
A.K.
>
>
-Rob
>
>
______________________________________________________
> Get Your
Private, Free Email at http://www.hotmail.com
JPEG image