Thanks, Theo, for this good advice about random-number generators:
>> - if you need determinism, write your own.
>> - do not rely upon an external function which will make your seed
>> produce a different result approximately every 8 years.
I would add more points:
* You MUST have portable source code for your generator (but you
probably don't need to, or should, write it yourself, unless
you are an expert in the field).
* If reproducibility of simulations matters (as it often does), set
the seed explicitly from your program source code or your input,
then print in your program output the first 50 to 100 random numbers
produced by your generator. A similar list from a later run can
then be compared with the earlier one to verify that both use the
same sequence.
* Avoid generators that use floating-point arithmetic: they are
difficult, perhaps impossible, to make platform independent.
* Beware of old algorithms: there have been huge improvements in
random-number generators in the last two to three decades
See the preamble comments in
http://www.math.utah.edu/pub/tex/bib/prng.bib
http://www.math.utah.edu/pub/tex/bib/prng.html
for pointers to papers that show the extreme subtlety of long-range
correlations in many generators that can derail simulations.
There are more recommendations, and programming subtleties, discussed
in chapter 7 of my book, The Mathematical-Function Computation
Handbook. However, the extensive prng.bib file above can lead you to
the original research papers, if it matters to you.
-------------------------------------------------------------------------------
- Nelson H. F. Beebe Tel: +1 801 581 5254 -
- University of Utah FAX: +1 801 581 4148 -
- Department of Mathematics, 110 LCB Internet e-mail: [email protected] -
- 155 S 1400 E RM 233 [email protected] [email protected] -
- Salt Lake City, UT 84112-0090, USA URL: http://www.math.utah.edu/~beebe/ -
-------------------------------------------------------------------------------