Mail Archives: djgpp/1997/06/08/18:08:02
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.
> 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).
This could vary well be true. My test for improvement was just looking
at the distribution of results (I was using the RNG to simulate N
dice). My original code just took the modulo of the random number and
the results were horible (sure I got a bell type curve, but every second
slot was about half (or maybe even 0) of what it should be (and the
period was noticably short). Using the code I posted, the curve I got
was much closer to what I calculated it should be and I didn't get a
glaringly obviously short period. Sure the period may have been even
shorter, but atleast it was out of phase with what I was doing.
> 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.
I can believe that (hehe, I'm listening to Icehouse's ``Don't beleive
Anymore'' right now :) as I have the impression RNG *in general* are
poorly understood with only a few having been poured over.
> If randomness of the numbers is very important to you, I would be careful
> with this method.
I agree with you totaly and thank you for your comments. If you can
point me in the right direction for information on testing RNGs, that
would be very kind of you.
> Francois
Bill
--
Leave others their otherness.
- Raw text -