3
$\begingroup$

I am running a SIMULINK model which has noise additions. At this moment we have a variable called seed which is initialized at zero.

seed = 0;

Then for every noise we set the seeds as follows:

noise_1_seed = seed + 1;
noise_2_seed = seed + 2;
noise_3_seed = seed + 3;
noise_4_seed = seed + 4;
noise_5_seed = seed + 5;

.            .   .    
.            .   .
.            .   .

noise_n_seed = seed + n;

We want to run this model with a Montecarlo approach and I am thinking that setting the seeds in this manner is not the proper way to do it as all of them depend on the initial value.

As we want the results to be reproducible, we can get the seeds from a uniform distribution and then save them for each run. I think saving the seeds at each run is our best approach but I would like to know if there is a better method to do it.

$\endgroup$

1 Answer 1

3
$\begingroup$

Perhaps I am misunderstanding what you want to do here, but I do not see why you require more than one seed for a reproducible analysis. The whole idea of a pseudo-random number generator (PRNG) is that it produces a series of pseudo-random numbers based on an initial seed. Once you set a single seed at the start of your analysis, you can then produce an arbitrarily long sequence of pseudo-random numbers, which means that you can produce one or more series of "random" noise of some desired length.

Unless there is some countervailing thing you are trying to achieve that I have not understood, the normal way to conduct a reproducible analysis involving multiple series of noise would be to set the seed once at the start of the analysis, and then produce each of the noise series you want to use. You do not need to reset the seed at the end of each noise series, since the whole idea of the PRNG is to produce a random series. Thus, you would ordinarily implement something like this:

#Set the seed
set.seed(34515987);

#Produce noise series'
noise_1 <- rnorm(length_1, 0, 1);
noise_2 <- rnorm(length_2, 0, 1);
noise_3 <- rnorm(length_3, 0, 1);
...
noise_n <- rnorm(length_n, 0, 1);
$\endgroup$
3
  • $\begingroup$ Thanks, the thing is that I want to run it 1000 times, so I need 1000 different initial seeds. So my doubt is: does the Montecarlo run will give me good results if the initial seeds are consecutive? I mean, in run 1 the seed is 1, in run 2 is 2 and so on. Or the initial seeds for each run have to be selected at random? $\endgroup$
    – Luis
    Jun 11, 2019 at 8:30
  • 1
    $\begingroup$ Couldn't you just use one seed to start it off and then use a loop for the runs? $\endgroup$
    – Ben
    Jun 11, 2019 at 10:24
  • $\begingroup$ Yes, I am doing that. I was just wondering if that is the correct way to do it. $\endgroup$
    – Luis
    Jun 12, 2019 at 12:15

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