I'm running a Monte Carlo simulation with 200+ input variables which I'm varying with a zero mean normal distribution via a random number generator. Does it matter if I set the seed once and then perform 1,000 runs, or do I need to reset the seed on the random number generator before each of the 1,000 runs?

As a quick test, I wrote up a test in Matlab to answer this question -- Are 10,000 random numbers pulled from the same seed nearly statistically equivalent to 10,000 random numbers pulled from 10,000 different seeds?

numCases = 10000;
% Same seed
Xsame = randn(numCases,1);

% Different Seeds
Xdifferent = zeros(numCases,1);
for ii = 1:10000
    Xdifferent(ii) = randn();

This produced means on the same order of magnitude, but I wasn't sure if that was good enough, or if I was missing some understanding of random number generators and Monte Carlo simulations.


1 Answer 1


For pseudo-random numbers, the seed is not there to "ensure randomness". In fact, it is quite the opposite: the seed is there to ensure reproducibility. You set the seed if you want to be able to run the same pseudo-random Monte Carlo experiments again and get the exact same results. For example if your scripts will be archived with an eventual publication.

It does not make sense to set the seed 10,000 times. You could set it once at the beginning of each of your 1,000 runs, but if they are quick and all run in a single loop, then setting the seed once at the beginning should be fine.

  • $\begingroup$ I suppose resetting and recording the seed for each run would enable rerunning specific run cases if desired instead of the full set. Or, to enable a continuation of runs if the full set cannot be run all at once. $\endgroup$
    – Patrick
    Commented Sep 15, 2016 at 23:02
  • 1
    $\begingroup$ @Patrick or if the runs are concurrent, as this sort of Monte Carlo is about as embarassingly parallel as it gets! $\endgroup$
    – GeoMatt22
    Commented Sep 16, 2016 at 2:05
  • 1
    $\begingroup$ To add a comment on this accurate answer, setting the seed anew for each of 10⁴ simulations will produce a pseudo-random sample only if the renewal mechanism for the seeds produces a sequence of pseudo-independent seeds. The easiest way to achieve this goal is to set the seed once and let the pseudo-random generator proceed through the generation of the 10⁴ values, as the associated seeds are then pseudo-independent. (I use pseudo everywhere to stress everything is deterministic.) $\endgroup$
    – Xi'an
    Commented Sep 16, 2016 at 6:42
  • $\begingroup$ @Xi'an good point, thank you for mentioning it explicitly! $\endgroup$
    – GeoMatt22
    Commented Sep 16, 2016 at 23:18
  • 1
    $\begingroup$ @pglpm: At each iteration of the 10⁴ calls, the RNG stores a current seed, e.g., the R .Random.seed object stored in the global environment. $\endgroup$
    – Xi'an
    Commented Apr 21 at 9:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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