I'm running the 64 bit version of R 2.13.0 on a PC with Windows 7. I'm using package snowfall to run parallel simulations using my computer's two quad-core processors, and I am concerned about the independence of random number generation. I've read the thread on this list here:

https://stat.ethz.ch/pipermail/r-sig-hpc/2010-June/000675.html

describing the clusterSetupRNGstream() function. However, when I try to run the function, I get an error message informing me that my cluster is "not a valid cluster". This does not seem to be correct, because I can run code on myCluster perfectly fine using sfLapply -- the issue is that random numbers from different nodes are identical. Here is the code that I am running followed by the error message:

myList <- as.list(matrix(seq(1,6),6,1))
myCluster <- sfInit(parallel=TRUE, cpus=6, type="SOCK")
nsim <- 5
sfExportAll()
clusterSetupRNGstream(myCluster)

# Error in checkCluster(cl) : not a valid cluster

mySimpleFunction <- function(nsim){rnorm(nsim,0,1)}
myOutput <- sfLapply(myList, function(q) mySimpleFunction(nsim=nsim))
myOutput

What could be causing this error, or what can I do to make random number generation independent among nodes? Note that I have tried:

sfLapply(myList, function(x) set.seed(ceiling(runif(1,0,1000000000))))

before calling my function. This seems to help, but does not completely solve the problem, as there remain streams of numbers from different nodes that are identical.

Best,

Jim

	[[alternative HTML version deleted]]

