Fixing set.seed for an entire session

后端 未结 6 1589
伪装坚强ぢ
伪装坚强ぢ 2020-12-09 01:59

I am using R to construct an agent based model with a monte carlo process. This means I got many functions that use a random engine of some kind. In order to get reproducibl

6条回答
  •  既然无缘
    2020-12-09 02:28

    I suggest that you set.seed before calling each random number generator in R. I think what you need is reproducibility for Monte Carlo simulations. If in a for loop, you can set.seed(i) before calling sample, which guarantees to be fully reproducible. In your outer function, you may specify an argument seed=1 so that in the for loop, you use set.seed(i+seed).

提交回复
热议问题