Skip to content

future (>= 1.24.0): Now future(…, seed = TRUE) forwards the RNG state #1

@HenrikBengtsson

Description

@HenrikBengtsson

Hi. FYI, future 1.24.0 is now on CRAN. A signficant change is:

  • Now future(…, seed = TRUE) forwards the RNG state in the calling R session. Previously, it would leave it intact.

So, your https://berkeley-scf.github.io/tutorial-dask-future/R-future#82-the-seed-when-using-futures-directly section can now be updated, because we now get:

library(future)
plan(multisession,workers=4)   # or some other plan
set.seed(1)
n <- 10
out <- list(); length(out) <- n
for(i in seq_len(n)) {
     out[[i]] <- future( {
       ## some code here as in foreach
       tmp <- rnorm(1e7)
       c(mean(tmp), sd(tmp))
     }, seed = TRUE)
}
sapply(out, value)
#>               [,1]          [,2]          [,3]         [,4]         [,5]
#> [1,] -7.323433e-05 -0.0001715487 -0.0005094992 0.0002571283 0.0003831295
#> [2,]  9.999894e-01  1.0001384289  1.0000917354 1.0001548200 0.9999650848
#>              [,6]         [,7]         [,8]         [,9]         [,10]
#> [1,] 2.627626e-05 2.848467e-06 0.0002893493 0.0004919797 -0.0002516645
#> [2,] 1.000183e+00 1.000202e+00 0.9996883582 1.0001180154  0.9998334065

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions