Mail Archives: djgpp/1998/04/14/13:02:49
Paul Derbyshire wrote:
>
> Is the subtractive_rng in the STL:
> * Better than random()?
> * As good as random()?
> * Between random() and rand()?
> * As good as rand()? or
> * Worse than rand()?
From Numerical Recipes:
... This is not based on the LCM at all, but rather on a subtractive
method. One might hope that its weakness, if any, are therefore of a
highly different character from the weakness, if any, from ran1
[a LCM generator] above. If you ever suspect trouble with one routine,
it is a good idea to try the other in the same application...
... Knuth's subtractive routine seems to be the timing winner among
protable routines. Unfortunately the subtractive method is not so
well studied, and not a standard...
From that I'd conclude that it is just as good as the better
one of rand() and random() (I always mix them up, so I'd better shut up)
Just *How good* your RNG has to be depends on your application.
For a simple game, the fastest usually suffices. If you want
to do some Monte Carlo integration or another type of
simulation, grab the best you can get. Press et al. give an
implementation of an RNG with a period length of > 2E10, so
that might be of interest for you,
--
Ciao
Tom
*************************************************************
* Thomas Demmer *
* Lehrstuhl fuer Stroemungsmechanik *
* Ruhr-Uni-Bochum *
* Universitaetsstr. 150 *
* D-44780 Bochum *
* Tel: +49 234 700 6434 *
* Fax: +49 234 709 4162 *
* http://www.lstm.ruhr-uni-bochum.de/~demmer *
*************************************************************
- Raw text -