RNGstreams
Parallel Independent Random Number Streams

### Description

Generate seeds for the L'Ecuyer random number generator to create multiple independent random number streams for use in parallel processing nodes.

### Usage

    clusterSetRNGStream(cl = NULL, iseed = NULL)
    nextRNGStream(seed)
    nextRNGSubStream(seed)

### Arguments

cl | a cluster object. Usually generated by makeCluster. If not provided, the default cluster is used.
iseed | an integer value. Used to generate a new seed for the "L'Ecuyer-CMRG" random number generator. If not provided, a random seed is selected.
seed | a seed suitable for the "L'Ecuyer-CMRG" random number generator.

### Details

- clusterSetRNGStream sets the random number generator for each node in the cluster to "L'Ecuyer-CMRG", with the initial seed set to produce an independent stream of random numbers on each node. This is useful if one wants to run separate simulations on the different nodes, using long non-correlated streams of random numbers for the different simulations.

  clusterSetRNGStream derives the first node's "L'Ecuyer-CMRG" seed from the iseed value, or a random value if this is not given. The second node seed is computed from nextRNGStream(firstNodeSeed), the third node seed is nextRNGStream(secondNodeSeed), and so on.

- Both nextRNGStream and nextRNGSubStream take a seed for the "L'Ecuyer-CMRG" random number generator and produce a new seed of the same kind. If seed is not suitable for the "L'Ecuyer-CMRG" random number generator, both functions produce an error message.

  This random number generator was designed to allow quickly skipping ahead a large number of random numbers, providing access to a new independent section within the random number sequence. nextRNGStream produces the seed that would be produced after generating 2^127 random numbers. nextRNGSubStream produces the seed that would be produced after generating 2^76 random numbers. The technique for generating random number streams and substreams is described in the reference LEcuyer (2002), Operations Research.

Value

clusterSetRNGStream | returns NULL invisibly.
nextRNGStream | returns a length-7 integer vector suitable for the "L'Ecuyer-CMRG" random number generator.
nextRNGSubStream | returns a length-7 integer vector suitable for the "L'Ecuyer-CMRG" random number generator.

References
L'Ecuyer, P. 1999. Good parameters and implementations for combined multiple recursive random number generators. Operations Research. Montreal, Canada: Univeristy of Montreal Volume 47, 159-164.
L'Ecuyer, P., et al. 2002. An object-oriented random-number package with many long streams and substreams. Operations Research. Montreal, Canada: Univeristy of Montreal Volume 50, 1073-5.
See Also
RNGkind, set.seed, makeCluster, mc.reset.stream
Examples

    RNGkind("L'Ecuyer-CMRG")
    runif(1)
    .Random.seed
    nextRNGStream(.Random.seed)
    nextRNGSubStream(.Random.seed)
    ## Not run:
    cl <- makeCluster(2)
    clusterSetRNGStream(cl, iseed = 123)
    # do some other parallel works on clusters
    stopCluster(cl)

    ## End(Not run)

Package parallel version 6.1.5-18
Package Index