[Rd] clusterSetRNGStream() question

J. R. M. Hosking JRMH001 at gmail.com
Sat Dec 10 22:00:10 CET 2011

In a vanilla R 2.14.0 GUI session (on Windows XP SP3):

 > library(parallel)
 > cl<-makePSOCKcluster(2)
 > RNGkind()
[1] "Mersenne-Twister" "Inversion"
 > clusterSetRNGStream(cl)
 > RNGkind()
[1] "L'Ecuyer-CMRG" "Inversion"
 > stopCluster(cl)

Is it intentional that clusterSetRNGStream() changes the RNG kind in
the master process?  The code of clusterSetRNGStream() suggests that
it is not: the old random number seed is saved in 'oldseed' and then
assigned to '.Random.seed':

   .Random.seed <- oldseed

line 45).  However, if the intent is to restore the old seed then
this assignment should be made in the global environment, e.g. via

   assign(".Random.seed", oldseed, envir = .GlobalEnv)

J. R. M. Hosking

 > sessionInfo()
R version 2.14.0 (2011-10-31)
Platform: i386-pc-mingw32/i386 (32-bit)

[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United 
States.1252    LC_MONETARY=English_United States.1252 LC_NUMERIC=C
[5] LC_TIME=English_United States.1252

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

More information about the R-devel mailing list