snowFT-rand: Random Number Generation

Description Usage Arguments Details Examples

Description

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

Usage

1
2
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

A single integer or a 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 when 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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
## Not run: 
# Generate 50 independent (normally distributed) random numbers 
# on 3 nodes using 10 RNG streams
cl <- makeClusterFT(3)
r <- 10
# reproducible results
for (i in 1:3) {
    clusterSetupRNG.FT(cl, streamper = "replicate", n = r, seed = 123)
    cat("\n")
    print(unlist(clusterApplyFT(cl, rep(5,r), rnorm, gentype = "RNGstream")[[1]]))
    
}

# non-reproducible results (method used in snow)
for (i in 1:3) {
    clusterSetupRNG.FT(cl, streamper = "node", seed = 123)
    cat("\n")
    print(unlist(clusterApplyFT(cl, rep(5,r), rnorm, gentype = "RNGstream")[[1]]))
}
stopClusterFT(cl)

## End(Not run)

snowFT documentation built on June 20, 2017, 9:16 a.m.