Last data update: 2014.03.03

R: Random Number Generation
snowFT-randR Documentation

Random Number Generation

Description

Initialize independent random number streams to be used in the cluster. It uses either the L'Ecuyer's random number generator (package rlecuyer required).

Usage

clusterSetupRNG.FT (cl, type = "RNGstream", streamper="replicate", ...)
clusterSetupRNGstreamRepli (cl, seed=rep(12345,6), n, ...)

Arguments

cl

Cluster object.

type

Type of the RNG. Currently, only "RNGstream" is supported. It initializes the L'Ecuyer's RNG.

streamper

Mode of the inititalization. Value "node" initializes one random number stream per node.
Value "replicate" initializes one stream per replicate.

...

Arguments passed to the underlying function (see details bellow).

seed

Vector of six integer values used as seed for the RNG.

n

Number of streams to be created. It should correspond to the number of replicates in the computation.

Details

clusterSetupRNG.FT calls one of the following functions, while passing arguments (cl, ...): For streamper="node", the snow function clusterSetupRNGstream is called; For streamper="replicate", the function clusterSetupRNGstreamRepli is called. In the latter case, the argument n has to be given that corresponds to the total number of streams created for the computation. This mode is used by clusterApplyFT. Note that using the function performParallel, the user does not need to initialize the RNG separately, since it is accomplished within the function.

clusterSetupRNGstreamRepli loads the rlecuyer package and on each node it creates n streams. The streams are named by their ordinal number.

Examples

## Not run: 
cl <- makeClusterFT(3)
r<-10
clusterSetupRNG.FT(cl, streamper="replicate",n=r, seed=rep(1,6))
res<-clusterApplyFT(cl,rep(5,10),rnorm)
stopCluster(res[[2]])
print(res[[1]])
  
## End(Not run)

Results