From: Thomas Demmer Newsgroups: comp.os.msdos.djgpp Subject: Re: rand() or random() Date: Thu, 06 Nov 1997 09:48:25 +0100 Organization: Lehrstuhl fuer Stroemungsmechanik Lines: 45 Message-ID: <34618459.EC2FCAEF@LSTM.Ruhr-UNI-Bochum.De> References: NNTP-Posting-Host: c64.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 John Payne wrote: > > Just out of interest, can anybody find to hand the algorithm that GCC uses > for random(). I'm doing some work on Genetic Algorithms where a fairly > decent aproximation of randomness is quite important and it would be nice > to know that's GCC's random() is decent. > > On Wed, 5 Nov 1997, Eli Zaretskii wrote: > > > > > This doesn't have to be so. If we have a good free RNG, we could > > replace `rand'. Writing a good RNG is not a trivial matter, but > > there's a lot of literature on the subject, including algorithms and > > public-domain code, out there. It shouldn't take somebody who knows > > about the subject matter more than a few days of work to come up with > > a reasonably good version. > > > > Any takers? A real good in terms of randomness algorithm can be found in one of the 90's Journal of Computational Physics and is by DEK, as far as I recall. I involves floating point ops, so it is probably slower than what is in libc right now. If there is real need for it, I can go on digging it out. If you are looking for other good ones, check Numerical Recipes by Press/Flannery/Teukolsky/Vetterling, Cambridge Press, UK, Seminumerical Algorithms, DEK, Addison Wesley -- 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 * *************************************************************