Mail Archives: djgpp/1997/06/06/05:24:05

Message-ID: <>
Date: Fri, 06 Jun 1997 10:35:27 +0200
From: Francois Charton <deef AT pobox DOT oleane DOT com>
Organization: CCMSA
MIME-Version: 1.0
To: billc AT blackmagic DOT tait DOT co DOT nz
CC: djgpp AT delorie DOT com
Subject: Re: One method for small random nuimbers
References: <2 DOT 2 DOT 32 DOT 19970604162434 DOT 0069d50c AT gate> <3395B097 DOT 5077 AT cornell DOT edu> <339830A6 DOT 672 AT blackmagic DOT tait DOT co DOT nz>

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.


- Raw text -

  webmaster     delorie software   privacy  
  Copyright 2019   by DJ Delorie     Updated Jul 2019