A not so Random Random
John.Maloney at disney.com
John.Maloney at disney.com
Fri Jun 11 20:51:08 UTC 1999
Re:
>Here's a question: If the algorithm were changed to use a modulus
>which fits into Squeak's 30-bit integers, would the resulting code run
>any faster than the float version, or still slower?
Probably quite a bit faster. But finding a set of parameters that
have all the desirable properties may not be trivial. The nice thing
about the Park-Miller parameters is that they have been studied
and deemed "good".
>> I wonder if this problem of getting stuck in a cycle is a side
>> effect of floating point roundoff and/or normalization? I would
>> expect the integer version of the algorithm to be free of this
>> problem; it was a well-tested and studied choice of parameters,
>> which is why we chose it.
>
>I did try some long runs of the generator with both integer and float
>computations, both seeded identically, and they were in complete
>agreement after a million or so iterations. The kinds of calculations
>involved look like they would tend to avoid roundoff errors, too, so
>my guess is the float calculations are probably exact.
Thanks for trying this. I'm pretty certain that the bug is due to
my "improved" initialization code (see the thread "Re: More on Random").
-- John
More information about the Squeak-dev
mailing list
|