generate_RNG_streams: Implementation RngStreams for N tasks according to Pierre...

Description Usage Arguments Details Value See Also Examples

View source: R/RandomNumberGenerator.R

Description

The function clusterSetRNGStream creates a stream for each worker/worker, and thus replicability can only be realized if each task is assigned to the same worker on repeated runs. This is usually not guaranteed with load-balancing parallel computations or when a long computation is being re-started from previous partially completed tasks/results. This implementation generates a stream for each unique tasks (instead for each worker) and thus avoids such problems.

Usage

1
generate_RNG_streams(N, seed = NULL, reproducible = TRUE)

Arguments

N

An integer. The number of streams to generate.

seed

An integer or NULL. The seed used by set.seed to set the (global/master) random generator, i.e., before generating the seeds of the streams.

reproducible

A logical value. If TRUE, then N are prepared. If FALSE, then instead NAs are returned.

Details

The current RNG kind, if required, must be captured before this function is called because the function sets the kind to “L'Ecuyer-CMRG” (see examples).

Value

A list of length N containing the seed for each stream.

See Also

clusterSetRNGStream

Examples

1
2
3
4
RNGkind_prev <- RNGkind()
seeds <- generate_RNG_streams(10, seed = 123)
# do work with random numbers
RNGkind(kind = RNGkind_prev[1], normal.kind = RNGkind_prev[2])

Burke-Lauenroth-Lab/rSFSW2 documentation built on Aug. 14, 2020, 5:20 p.m.