Mail Archives: djgpp/1997/06/13/12:10:23
Bill Currie wrote:
>
> Francois Charton wrote:
> >
> > Bill Currie wrote:
> > >
> > > Basicaly, I treat the number received from the main RNG as a
> > > bit stream and pull off the bits as needed.
> > >
> > I read about such a method being a bad thing in several books
> > (Numerical Recipes warns a lot against this, and I remember reading
> > something about it in Knuth, I'll dig it out tonight).
>
> If you can send me a quote, that would be apreciated.
>
i realize i am not the person to whom this request was directed, but in
light of the recent discussions, i think a few quotes can be useful.
(you can download chapters from 'merical recipes' at www.std.com/~nr/)
Numerical Recipes in C, 2nd ed. p.277:
(Linear congruential) generators have their low order (least
significant) bits much less random than their high order bits. If you
want to generatea random integer between 1 and 10, you should always do
it using high order bits as in:
j = (int)(10.0*rand()/(RAND_MAX+1.0));
and never by anything resembling
j = 1 + (rand() % 10);
more related to what bill currie was proposing ("I treat the number
received from the main RNG as a bit stream and pull off the bits as
needed.") is the remark on p.299, but their warning concerns the
opposite of what he wants to do:
A word of caution is: Don't use sequential bits from these routines as
the bits of a large, supposedly random, integer ...
pp.296-300 of their book is devoted to generation of random sequences of
bits.
-- Sinan
- Raw text -