[Mingw-users] RE: Chaos math library!!! From: FMGCFMGC - 2004-09-23 09:36 ```Hello! Only for the record here are two simple-to-use random number generators Marsaglia-Multicarry: --------------------- You have a C implementation in the file src/nmath/standalone/sunif.c of R-1.9.1 source (under the GPL). Very easy to use, and of good quality at the time it was proposed: The output of the R command (R-1.8.1 patched): > help(RNGkind) gives: "Marsaglia-Multicarry"': A _multiply-with-carry_ RNG is used, as recommended by George Marsaglia in his post to the mailing list 'sci.stat.math'. It has a period of more than 2^60 and has passed all tests (according to Marsaglia). The seed is two integers (all values allowed) Here is the reference (again from the output of 'help(RNGkind)'): Marsaglia, G. (1997) _A random number generator for C._ Discussion paper, posting on Usenet newsgroup 'sci.stat.math' on September 29, 1997. Mersenne-Twister: ----------------- http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html It's is the default RNG in R-1.8.1. Originally released under the GPL, but the authors decided to let MT be used in commercial products freely. we decided to let MT be used for any purpose, including commercial use See: http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/MT2002/elicense.html Hope it helps! Francisco ```
 [Mingw-users] [mingw - C/C++] RE: Chaos math library!!! From: SourceForge.net - 2004-09-22 19:54 ```Read and respond to this message at: https://sourceforge.net/forum/message.php?msg_id=2771420 By: aaronwl exp() is in . The rand() is Microsoft's rand(). Several Windows programs depend on its specific characteristics, and so it probably can't be improved. Note that if you need any particular characteristics for your pseudo random numbers, do not use rand(). In particular, if you have particular range, distribution, entropy, security, or other requirements, do not use rand(). This is true of all compilers; rand() is expected only to be only very roughly uniform and fairly fast. Aaron W. LaFramboise ______________________________________________________________________ You are receiving this email because you elected to monitor this forum. To stop monitoring this forum, login to SourceForge.net and visit: https://sourceforge.net/forum/unmonitor.php?forum_id=286529 ```
 [Mingw-users] [mingw - C/C++] RE: Chaos math library!!! From: SourceForge.net - 2004-09-22 21:50 ```Read and respond to this message at: https://sourceforge.net/forum/message.php?msg_id=2771576 By: johngaughan I agree. For a quick and dirty random number, rand() is fine, but srand() it first. Using the clock as a seed should be good, although most OSes have API calls for better granularity, so more values. E.g. two programs started during the same second will have the same sequence of random values, unless you use a function that gives milliseconds (even then there is a chance...) Anyway, I think the best solution for high-quality pseudo-random numbers is to code your own, but this requires application of advanced discrete math, probability, and statistics. Even among computer scientists, not everyone has the skill to make a *good* pseudo-random number generator. Dr. Knuth has a decent generator in his book, with code listed at his site. I tweaked it a little bit and ran some tests, and it appears to work fairly well, although it is slower and uses more static memory than the default rand(). A better solution would couple a generator such as Dr. Knuth's with a good entropy source external to the computer. However, this gets way off topic for the MinGW list and enters the realm of pure computer science... Here is a link to Dr. Knuth's site. Look under the RANARRAY heading. http://www-cs-faculty.stanford.edu/~knuth/programs.html#rng ______________________________________________________________________ You are receiving this email because you elected to monitor this forum. To stop monitoring this forum, login to SourceForge.net and visit: https://sourceforge.net/forum/unmonitor.php?forum_id=286529 ```
 Re: [Mingw-users] [mingw - C/C++] RE: Chaos math library!!! From: Greg Chicares - 2004-09-23 00:41 ```> By: johngaughan We're getting beyond the OP's needs, so I'll just revert to simple email. > Dr. Knuth has a decent generator in his book, > with code listed at his site. There are some carefully-designed RNGs at boost.org . Just a header that you drop into your program, last time I looked. The documentation is impressive, too. ```
 Re: [Mingw-users] [mingw - C/C++] RE: Chaos math library!!! From: Kuba Ober - 2004-09-24 20:05 ```On =C5=9Broda 22 wrzesie=C5=84 2004 08:41 pm, Greg Chicares wrote: > > By: johngaughan > > We're getting beyond the OP's needs, so I'll just > revert to simple email. > > > Dr. Knuth has a decent generator in his book, > > with code listed at his site. > > There are some carefully-designed RNGs at boost.org . > Just a header that you drop into your program, last > time I looked. The documentation is impressive, too. AFAIK a fairly good general-purpose one (dunno if boost implements it, thou= gh)=20 is called Mersenne Twister. It gives very long sequences, considering that= =20 the code is neither too expensive nor too complex. Cheers, Kuba Ober ```