if (FALSE) {
# Generate 50 independent (normally distributed) random numbers
# on 3 nodes using 10 RNG streams
cl <- makeClusterFT(3)
r <- 10
# reproducible results
for (i in 1:3) {
clusterSetupRNG.FT(cl, streamper = "replicate", n = r, seed = 123)
cat("\n")
print(unlist(clusterApplyFT(cl, rep(5,r), rnorm, gentype = "RNGstream")[[1]]))
}
# non-reproducible results (method used in snow)
for (i in 1:3) {
clusterSetupRNG.FT(cl, streamper = "node", seed = 123)
cat("\n")
print(unlist(clusterApplyFT(cl, rep(5,r), rnorm, gentype = "RNGstream")[[1]]))
}
stopClusterFT(cl)
}
Run the code above in your browser using DataLab