From JRMH001 at gmail.com  Sat Dec 10 22:00:10 2011
From: JRMH001 at gmail.com (J. R. M. Hosking)
Date: Sat, 10 Dec 2011 16:00:10 -0500
Subject: [Rd] clusterSetRNGStream() question
Message-ID: <jc0h8p$jh3$1@dough.gmane.org>

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

(https://svn.r-project.org/R/trunk/src/library/parallel/R/RngStream.R,
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)

locale:
[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



[Rd] clusterSetRNGStream() question
J. R. M. Hosking