Different random number generation between OS

Does anyone have experience in situations where set.seed gives different results depending on the operating system (OS). I remember encountering a similar situation in a class on R before some people generated different random sequences using rnorm, even though the initial seed was the same. Now I give the course myself and do not face the same problem with rnorm; all my students get the same sequence, regardless of OS. Interestingly, the same problem exists with the mvrnorm function of the MASS package.

Any understanding would be greatly appreciated - Mark

In this example:

require(MASS) set.seed(123) a <- rnorm(10, mean=10, sd=3) b <- rnorm(10, mean=5, sd=2) df <- data.frame(a,b) C <- cov(df) M <- mvrnorm(n=10, c(10,5), C) df C M 

Installs on my 64-bit version of Windows 7 OS version 2.14.1 .:

 > df ab 1 8.318573 7.448164 2 9.309468 5.719628 3 14.676125 5.801543 4 10.211525 5.221365 5 10.387863 3.888318 6 15.145195 8.573826 7 11.382749 5.995701 8 6.204816 1.066766 9 7.939441 6.402712 10 8.663014 4.054417 > C ab a 8.187336 3.431373 b 3.431373 4.310385 > M ab [1,] 13.270535 6.158603 [2,] 10.375011 5.737871 [3,] 13.514105 5.476411 [4,] 12.681956 5.020646 [5,] 12.352333 4.927746 [6,] 15.177508 6.810387 [7,] 8.114377 2.925225 [8,] 9.529744 4.834451 [9,] 12.903550 7.232715 [10,] 6.251907 3.481789 

Edit: It might be useful to find out if anyone got these results and which OS or version of R were used.

+6
source share
1 answer

I heard about people changing RNGKind, sometimes without realizing it, downloading and launching a package that changed the generator or some other script that made the changes. If this were so, then the same seed would lead to different random numbers. A fresh run of R (without loading different packages or other scripts) should generate the same random numbers from the same seed.

0
source

Source: https://habr.com/ru/post/920912/


All Articles