# References and Best practices for setting seeds in pseudo-Random Number Generation

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.

• 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.
– whuber
Oct 23, 2014 at 20:31
• @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? Oct 23, 2014 at 20:49
• 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."
– whuber
Oct 23, 2014 at 21:01
• @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. Oct 23, 2014 at 21:42
• Assuming your PRNG is good, why would setting seeds with a pattern make any difference, isn't that the whole point of PRNGs? Oct 23, 2014 at 23:04