[R-sig-hpc] How to attain randomness and reproducibility
David Lundquist
d@v|dp@tr|ck|undqu|@t @end|ng |rom gm@||@com
Fri Dec 8 19:49:31 CET 2023
Currently, I am using the foreach package in R to do the following (in
R-flavored pseudocode):
*set.seed(1)*
*foreach square in big grid of parameter combinations **%dopar%*
* foreach i in 1:replication_count **%do%*
* do some computation, output a row, and rbind it*
*save the df generated by rbinding*
Possible virtues of the preceding: seed is made clear
Possible vices of the preceding: failure of randomness
One might therefore try moving set.seed to the inner loop:
*foreach square in big grid of parameter combinations %dopar%*
* foreach i in 1:replication_count **%do%*
*set.seed(i)*
* do some computation, output a row, and rbind it*
*save the df generated by rbinding*
Possible virtues of the preceding: seed sequence is explicit
Possible vices of the preceding: we've programmed the seeds to be equal
I'd appreciate any advice, especially if there's an easy reference/vignette
that can be pointed to, a la
https://cran.r-project.org/web/packages/doRNG/vignettes/doRNG.pdf
https://cran.r-project.org/web/packages/dqrng/vignettes/parallel.html
[[alternative HTML version deleted]]
More information about the R-sig-hpc
mailing list