Mail Archives: djgpp/1997/06/06/05:24:05
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).
In general, for RNG, "handmade" methods are always dangerous, and by
slightly tweaking any good RNG, you can make a bad one out of it. An
example of this was DJGPP rand() from a previous version (v2.00 and
before): it used the ANSI rand() function, not excellent, but not
terrible either, but instead of returning the number, it did some bit
exchanging and shifting on the result; this looked like a good idea, but
actually the resulting generator was bad (it had a low period).
I believe books warn against interpreting random numbers as random
sequences of bits because the subject (independence of the bits inside a
random number) has not been researched enough.
If randomness of the numbers is very important to you, I would be careful
with this method.
Francois
- Raw text -