Mail Archives: djgpp/1997/06/04/04:02:42
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 -