set.seed in function vs clusterSetRNGStream: switching from one to another
0
0
Entering edit mode
ZheFrench ▴ 30
@zhefrench-11689
Last seen 16 days ago
France

I was using set.seed inside a function of my package.
I realized then it was not recommended as a good practice.
Due to the use of parallelization , set.seed was ineficient when calling from the main script.
So I switch to clusterSetRNGStream and now it seems to work well without including set.seed in the function of the package.

Still I am not able to reproduce the exact same sampling with clusterSetRNGStream .

I was using set.seed (9832) directly inside my package and then I tried to reproduce the results using same seed (see code that follows).
Any idea how I could reproduce using the same exact same sampling from set.seed (9832) using clusterSetRNGStream ?

n.proc <- 2
cl     <- makeCluster(n.proc)
clusterSetRNGStream(cl, iseed = 9832)
registerDoParallel(cl)

# Then I'm Calling Package functions...

parallel seed • 62 views