delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/06/04/04:02:42

Message-ID: <33951C40.410D@pobox.oleane.com>
Date: Wed, 04 Jun 1997 09:41:52 +0200
From: Francois Charton <deef AT pobox DOT oleane DOT com>
Organization: CCMSA
MIME-Version: 1.0
To: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
CC: djgpp AT delorie DOT com
Subject: Re: Random numbers/George
References: <Pine DOT SUN DOT 3 DOT 91 DOT 970604093901 DOT 2271A-100000 AT is>

Eli Zaretskii wrote:
> 
> On 3 Jun 1997, George Foot wrote:
> 
> > Apparently, random() is a `more' random
> > generator than rand(); presumably the reason the portable rand() function
> > uses a worse generator is that the algorithm is specified in the standard,
> > although I really don't know (does anyone?).
> 
> I think at least part of the reason for what `rand' does is that good
> random generators are notoriously hard to invent, and those which
> exist aren't always free.  DJGPP's libc needs to be totally free.

Two other reasons: 

- the algorithm used by random() has been less studied than the linear 
congruential thing, which rand() uses. Thus, rand() has *known* strenth 
and failures, while random() is a little more "murky", this may be a 
problem when using random numbers for simulation.

- rand() is much faster than random() 

Anyway, I'd like to point out that if you need "informal" random numbers, 
like in games, raytracers... rand() is probably more than enough. On the 
contrary, if you need "really" random numbers, for statistics, Monte 
Carlo integration and the like, then you'd better avoid using any 
"canned" function like rand() or random(), and program your own (or, 
rather, several) RNG, taken from an academic book, and with known 
properties.

Francois

- Raw text -


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