Mail Archives: djgpp/1997/11/06/08:31:20
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 *
*************************************************************
- Raw text -