Re: Random Numbers
- From: nospam@xxxxxxxxxxxxx (Richard E Maine)
- Date: Thu, 29 Jun 2006 08:59:30 -0700
dpb <dpbozarth@xxxxxxxx> wrote:
Calling RANDOM_SEED w/o any arguments resets the seed based on the
current CPU date and time.
That is *NOT* guaranteed by the standard. The standard just says that it
assigns a processor-dependent seed. There is no requirement or even
implication that it is based on the data and time. I think that might
have been the intent of the original author of that part of the
standard; I think I recall him once saying so. But unfortunately, he
didn't manage to write it down that way or even communicate that to the
rest of the committee. By the time he noticed that the written words
didn't say what he intended, it was way too late because multiple
implementations had followed what was actually written in the standard.
There's a lesson somewhere in here about technical writing. Some (maybe
even most; I don't have all the data handy) compilers do it that way. I
regard that as desireable behavior, but it is not guaranteed. You could
well find that it is set to the same starting seed each time, which
isn't at all what you want.
The two most popular methods of assuring that you get a new seed eith
each run are:
1. Set the starting seed yourself based on date/time. See the
date_and_time and random_seed intrinsics in any text. It isn't hard to
throw together something using those two intrinsics, and for the
described purpose, you aren't likely to be too picky about the
statistical properties.
2. Save the seed to a file somewhere. Initialize the seed from the file
when you start (with a default action in case the file doesn't exist).
Save the latest seed to the file when you terminate (or after you are
otherwise done with it for a run). This does require access to the file,
which might be an issue if multiple people are running the program.
--
Richard Maine | Good judgment comes from experience;
email: my first.last at org.domain| experience comes from bad judgment.
org: nasa, domain: gov | -- Mark Twain
.
- Follow-Ups:
- Re: Random Numbers
- From: Steven G. Kargl
- Re: Random Numbers
- From: dpb
- Re: Random Numbers
- References:
- Random Numbers
- From: CTallant
- Re: Random Numbers
- From: dpb
- Random Numbers
- Prev by Date: Re: Random Numbers
- Next by Date: How to Find Memory Used (IVF 9.1, WinXP)
- Previous by thread: Re: Random Numbers
- Next by thread: Re: Random Numbers
- Index(es):
Relevant Pages
|