From: Thomas Demmer Newsgroups: comp.os.msdos.djgpp Subject: Re: subtractive_rng Date: Tue, 14 Apr 1998 13:03:39 +0200 Organization: Lehrstuhl fuer Stroemungsmechanik Lines: 42 Message-ID: <3533428B.1E67A683@LSTM.Ruhr-UNI-Bochum.De> References: NNTP-Posting-Host: bvb.lstm.ruhr-uni-bochum.de Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk 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 * *************************************************************