Bug in the scaling of randoms ...

Dimitre Novatchev dnovatchev@yahoo.com
Mon, 6 May 2002 12:28:29 -0700 (PDT)


Thank you!

--- oleg@pobox.com wrote:
[nice proof snipped]

> Thus the correct algorithm reads
> 
> > scaleSequence :: Int -> Int -> [Int] -> [Int]
> > scaleSequence s t
> >   = map scale
> >     where
> >       scale n = (n*range) `div` maxn + s
> >       range   = t - s
> >       maxn    = modulus - 1
> >       modulus = 65536
> 
> Given your example,
> Main> any (==966) (scaleSequence 1 966 ([65231] ++ [1..965]
> ++[65565]))
> True
> Main> any (>966) (scaleSequence 1 966 ([65231] ++ [1..965]
> ++[65565]))
> False 

In your examples you added one more element to the end of the list. Its
value is greater than maxn -- maybe I'm missing something?

Cheers,
Dimitre Novatchev.


__________________________________________________
Do You Yahoo!?
Yahoo! Health - your guide to health and wellness
http://health.yahoo.com