本文介绍了set.seed 与 R 2.15.2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
My understanding is that using set.seed
ensures reproducibility but this is not the case with the following R code in R 2.15.2
. Am I missing something here?
set.seed(12345)
rnorm(5)
[1] 0.5855288 0.7094660 -0.1093033 -0.4534972 0.6058875
rnorm(5)
[1] -1.8179560 0.6300986 -0.2761841 -0.2841597 -0.9193220
解决方案
set.seed()
reinitializes the random number generator.
set.seed(12345)
rnorm(5)
[1] 0.5855288 0.7094660 -0.1093033 -0.4534972 0.6058875
set.seed(12345)
rnorm(5)
[1] 0.5855288 0.7094660 -0.1093033 -0.4534972 0.6058875
set.seed(12345)
rnorm(5)
[1] 0.5855288 0.7094660 -0.1093033 -0.4534972 0.6058875
这篇关于set.seed 与 R 2.15.2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!