prepare_RNG_streams: Implementation of Pierre L'Ecuyer's RngStreams for N tasks

Description Usage Arguments Details Value Examples

Description

The function parallel::clusterSetRNGStream creates a stream for each slave/core, and thus replicability can only realized if each task is assigned to a the same slave at each repeated call. This is usually not guaranteed with load-balancing parallel computations or when a long computation is being re-started continuing on previously produced results. This implementation generates a stream for each unique tasks and thus avoids those two problems.

Usage

1

Arguments

N

An integer. The number of streams to generate.

iseed

An integer or NULL. The seed used by set.seed before generating the streams.

Details

The current RNG kind, if required, must be captures before calling this function because the function sets it to "L'Ecuyer-CMRG" (see examples).

Value

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

Examples

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

dschlaep/ecotoner documentation built on May 15, 2019, 2:57 p.m.