I'm trying to use the RNG of the package RcppZiggurat on a snow cluster. To seed the RNG on each node, I use L'Ecuyer's algorithm built into clusterSetupRNG. However, the sequence of random numbers turns out to be the same on each node. The result of the code stays exactly the same even if I run it without the clusterSetupRNG-command.
Here's what I tried:
library(RcppZiggurat)
library(snow)
myFun <- function(i){
rn <- zrnormLZLLV(10)
return(rn)
}
nodes <- rep("localhost",2)
cl <- makeCluster(nodes, type="SOCK")
vars <- list("zrnormLZLLV")
clusterExport(cl=cl,list=vars,envir=environment())
clusterSetupRNG(cl=cl,type="RNGstream")
res <- parLapply(cl,c(1,2,3,4),myFun)
res
Does anybody have an idea how I can make this work? Of course I could always resort to the standard RNG rnorm, but it would be nice to have the speed of RcppZiggurat also on a cluster.
Thanks a lot for your help!
Aucun commentaire:
Enregistrer un commentaire