MATLAB Answers

seed for Monte Carlo

8 views (last 30 days)
charisios grivas
charisios grivas on 4 Dec 2019
Commented: Jeff Miller on 4 Dec 2019
I am running a Monte carlo simulation and I have set the seed outside the monte carlo simulation. However, one of my basic assumptions is that two variables are independent. I am wondering whether the two variables generated by using the same seed will be dependent so that I will have to change the seed for each iteration of the monte carlo simulation. If the latter holds, how do i do that? I have calculated the correlation between the two and it is close to 0.(However zero correlation does not imply independence)

  0 Comments

Sign in to comment.

Answers (1)

Jeff Miller
Jeff Miller on 4 Dec 2019
It sounds like you would be better off not to set the seed at all--just use MATLAB's default seed, which is different every time it starts.
Usually the only reason for setting the seed is to make sure that you can recreate the same set of random values in a later run, and it doesn't sound like you want to do that.

  2 Comments

Guillaume
Guillaume on 4 Dec 2019
"just use MATLAB's default seed, which is different every time it starts."
Hum, no actually. Matlab default seed is always the same: 0. If you restart matlab, you're guaranteed to get the exact same sequence of numbers every time.
The easiest way to make sure you get a different random sequence every time you restart matlab is with:
rng('shuffle')
On the other hand, if you don't restart matlab between runs of the monte-carlo simulation, it doesn't really matter what the starting seed was, the numbers will be random from run to run, as long as you don't reset the seed between each run.
Jeff Miller
Jeff Miller on 4 Dec 2019
Yikes, that's good to know. Will add rng('shuffle') to my startup.

Sign in to comment.

Sign in to answer this question.

Tags