[R] rsprng, snow, rmpi interactions

Ross Boylan ross at biostat.ucsf.edu
Wed Mar 5 03:33:01 CET 2008


The proper use of SPRNG is a little unclear to me in each of these
packages, even more so when I put them all together.  

My immediate question: in snow I did clusterSetupSRNG.  If a later want
to (re) set the system to a known seed, how do I do it?  That is, I want
each distributed process to recreate exactly the same random numbers
that it did before; I assume SPRNG assures the streams are independent
betweeen processes.

Here's what I did, trying to stick within SNOW to avoid trouble (from
memory):
lamboot
start up R
library(snow)
library(rsprng)
library(rmpi)
cl<-makeMPIcluster(11)
clusterSetupSPRNG(cl, seed=123)
clusterEvalQ(cl, source("mycode.R"))
r<-parSapply(cl, seq(1000), function(i) doMyThing()))

Any comments on that?  For example, would sticking to Rmpi and using
parSim make sense (I'm not using seq(1000) for anything but getting that
many repetitions.)?

Both rmpi and rsprng had a bunch of functions for setting of the
parallel random number generators.  Could anyone clarify if these are
alternatives, or steps that must be run in sequence, or something else?

Is there a way to get multiple distributed random number streams.  For
example, in each simulation I may generate random variables X, Y, and Z.
Some simulations skip generating X, but I'd like to get the same random
sequences for Y as I did before.  I assume that if X, Y and Z are each
generated off a separate stream this is possible, but I'm not sure if
it's possible within the existing libraries.

Thanks for any help.

Ross Boylan



More information about the R-help mailing list