Create a set of initial random number seeds suitable for using within a distributed context (over multiple processes or nodes) at a level higher than a single group of synchronised threads.

dust_rng_distributed_state(
  seed = NULL,
  n_streams = 1L,
  n_nodes = 1L,
  algorithm = "xoshiro256plus"
)

dust_rng_distributed_pointer(
  seed = NULL,
  n_streams = 1L,
  n_nodes = 1L,
  algorithm = "xoshiro256plus"
)

Arguments

seed

Initial seed to use. As for dust_rng, this can be NULL (create a seed using R's generators), an integer or a raw vector of appropriate length.

n_streams

The number of streams to create per node. If passing the results of this seed to a dust object's initialiser (see dust_generator) you can safely leave this at 1, but if using in a standalone setting, and especially if using dust_rng_distributed_pointer, you may need to set this to the appropriate length.

n_nodes

The number of separate seeds to create. Each will be separated by a "long jump" for your generator.

algorithm

The name of an algorithm to use. Alternatively pass a dust_generator or dust object here to select the algorithm used by that object automatically.

Value

A list of either raw vectors (for dust_rng_distributed_state) or of dust_rng_pointer

objects (for dust_rng_distributed_pointer)

Details

See vignette("rng_distributed") for a proper introduction to these functions.

Examples

dust::dust_rng_distributed_state(n_nodes = 2)
#> [[1]]
#>  [1] 8d a2 7e f2 dc 24 fa 89 45 7e d3 2a c5 d2 2a cf a6 10 e2 49 a6 3e b9 8c c6
#> [26] e0 23 54 77 b6 75 7b
#> 
#> [[2]]
#>  [1] 90 9c 59 93 55 7d 9e b8 19 07 9a d6 1c d0 98 0b 1d 13 83 b1 59 30 8f 22 64
#> [26] d0 79 ab 1e ee 1b 5b
#> 
dust::dust_rng_distributed_pointer(n_nodes = 2)
#> [[1]]
#> <dust_rng_pointer>
#>   Public:
#>     algorithm: xoshiro256plus
#>     initialize: function (seed = NULL, n_streams = 1L, long_jump = 0L, algorithm = "xoshiro256plus") 
#>     is_current: function () 
#>     n_streams: 1
#>     state: function () 
#>     sync: function () 
#>   Private:
#>     is_current_: TRUE
#>     ptr_: externalptr
#>     state_: 64 a2 c0 67 4a d6 59 d7 f4 58 2b 73 4f d2 da 23 a2 b3 02 ...
#> 
#> [[2]]
#> <dust_rng_pointer>
#>   Public:
#>     algorithm: xoshiro256plus
#>     initialize: function (seed = NULL, n_streams = 1L, long_jump = 0L, algorithm = "xoshiro256plus") 
#>     is_current: function () 
#>     n_streams: 1
#>     state: function () 
#>     sync: function () 
#>   Private:
#>     is_current_: TRUE
#>     ptr_: externalptr
#>     state_: 6e 75 1f c8 ca a4 f9 95 d7 a2 84 0f 53 3d c8 41 f3 c2 c1 ...
#>