Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify reproducible parallel random streams in R #38

Open
rstub opened this issue Dec 17, 2019 · 1 comment
Open

Simplify reproducible parallel random streams in R #38

rstub opened this issue Dec 17, 2019 · 1 comment
Labels
enhancement New feature or request

Comments

@rstub
Copy link
Member

rstub commented Dec 17, 2019

The parallel vignette shows how one can get reproducible parallel RNG streams in principle. However, this is not very convenient. It would be nice to have an analogue function for clusterSetRNGStream, e.g.:

dqclusterSetRNGStream <- function(cl = NULL, iseed =  NULL) {
    if (is.null(cl))
        cl <- parallel::getDefaultCluster()
    if (is.null(iseed))
        iseed <- dqrng::generateSeedVectors(1L)[[1L]]
    invisible(parallel::clusterApply(cl,
                                     seq_along(cl),
                                     function(seed, stream) {
                                         dqrng::dqset.seed(seed, stream)},
                                     seed = iseed))
}
  • This is just one way to achieve reproducibility, see https://pat-s.me/reproducibility-when-going-parallel/ by @pat-s for more details.
  • It would be nice to not use R's RNG here via dqrng::generateSeedVectors. Instead, the random seed could be taken from dqrng's RNG.
  • It would make sense to offer the possibility to set the RNG kind as well.
@rstub rstub added the enhancement New feature or request label Dec 17, 2019
@rstub
Copy link
Member Author

rstub commented Aug 5, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant