10
$\begingroup$

In this document, that concerns the "set seed" command, Stata people discuss issues related to the setting of seeds when generating pseudo-random numbers.

A notable "don't" is "don't use serially the sequence of natural numbers as seeds, because this has a pattern and endangers pseudo-randomness".

A only one-quarter-jokingly notable "do", is to set just one seed during your lifetime, and then record the "state" of the generated process at the end of each experiment, so that the next experiment will continue at the point where the process has stopped.

Obviously, the above advice depends on the expected count of pseudo-random numbers one will generate in his research life-time. Perhaps a Mersenne twister would cover the life-time needs of many researchers...

Now, I am not greatly experienced as regards PRNGs in theory or in practice, so I cannot argue about these suggestions -they should be proven valid or invalid on theoretical grounds and hard mathematical statistics.

So, my questions are

1) Can you help explaining or invalidating the advices given above, or point to a reference that deals with such issues?

2) Can you provide references that offer "best practices" in setting seeds?

3) How do you go about it in your own work, and why?

As an example for question 3), suppose that for a Monte Carlo study, you want to generate $m$ samples each of size $n$, and that your $\text{PRNG}$ has a period sufficiently larger than $mn$. Would you generate all $mn$ pseudo-random numbers with one seed, or you have the habit of changing seeds, say, per sample? (but that's just for illustration -I believe more general answers are worthwhile here).

A related thread (although much more focused) is
Set seed before each code block or once per project?

I have the feeling this perhaps should be a community wiki, the mods please decide on that.

$\endgroup$
  • 4
    $\begingroup$ That Stata manual page makes important implicit assumptions about why one is using a seed. The main reason I use seeds (in my postings here on CV) is to create reproducible examples. In order to demonstrate that I haven't fiddled with the seed until the example was to my liking(!), I (almost) always use the same seed. This so flagrantly contradicts the Stata advice because I have a different purpose than they must have in mind (which is unstated). The moral here is that best practices depend upon the purpose. $\endgroup$ – whuber Oct 23 '14 at 20:31
  • $\begingroup$ @whuber My feeling is that the advice given in the document that I mention aims at preserving both "randomness" and reproducibility of the series used (through the recording of the "state" of the process, as they say). These goals appear worth pursuing in any set up, whatever the purpose of the research, no? $\endgroup$ – Alecos Papadopoulos Oct 23 '14 at 20:49
  • 1
    $\begingroup$ Sure they are worthwhile--but that does not justify making them into definite "dos" and "don'ts" as expressed by that manual page. The problem with such uncategorical dicta is that others--such as lawyers--will be led to think that any contrary practice is inherently wrong, regardless of purpose or circumstances. It is important to leave room for judgment in the practice of statistics! In particular, let us please not confound recommendations for the use of software with "best practices." $\endgroup$ – whuber Oct 23 '14 at 21:01
  • $\begingroup$ @whuber The fact that I used as "stimulus" a document linked to a specific software does not make my question being about "recommendations for the use of software". The questions posed are obviously about policies used by researchers in conducting statistical research, so I see no confounding here. $\endgroup$ – Alecos Papadopoulos Oct 23 '14 at 21:42
  • 3
    $\begingroup$ Assuming your PRNG is good, why would setting seeds with a pattern make any difference, isn't that the whole point of PRNGs? $\endgroup$ – purple51 Oct 23 '14 at 23:04
3
$\begingroup$

For what it's worth, this is based on experience and not on mathematical analysis:

I think that unless you're doing cryptography, where subtle patterns can be very bad, which seed you set doesn't make a difference, as long as you use accepted good PRNGs like Mersenne Twister and not old ones like linear congruential generators. As far as I know, there is no way that you can tell what random number will come out from a given seed without actually running the PRNG (assuming it's a decent one), otherwise you would just take that new algorithm and use that as your random number generator.

Another perspective: do you think that any subtle patterns in your Monte-Carlo simulation are likely to be of a larger magnitude than all the measurement error, confounding, and error introduces by other modeling assumptions?

I would just use one random seed at the beginning for reproducibility, and not set one before each call, unless I'm doing debugging, where I need to make sure two different algorithms produce the same result for the exact same input data.

Disclaimer: if you simulating nuclear reactors or missile control systems or weather forecasting, best to consult domain experts, I take no responsibility in that case.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.