snowFT-rand {snowFT} | R Documentation |
Initialize independent random number streams to be used in the cluster. It uses either the L'Ecuyer's random number generator (package rlecuyer required) or the SPRNG generator (package rsprng required).
clusterSetupRNG.FT (cl, type = "RNGstream", streamper="replicate", ...) clusterSetupRNGstreamRepli (cl, seed=rep(12345,6), n, ...)
cl |
Cluster object. |
type |
type="RNGstream" (default) initializes the
L'Ecuyer's RNG. type="SPRNG" initializes the
SPRNG generator. |
streamper |
streamper="node" initializes one random
number stream per node.streamper="replicate" (default) initializes one stream per replicate. |
... |
Arguments passed to the underlying function (see details bellow). |
seed |
Integer value (SPRNG) or a vector of six integer values (RNGstream) used as seed for the RNG. |
n |
Number of streams to be created. It should correspond to the number of replicates in the computation. |
clusterSetupRNG.FT
calls (subject to its argument values) one of
the following functions, passing arguments (cl, ...)
: If the
"SPRNG" type is used, then in case of
streamper="node"
the snow function clusterSetupSPRNG
is
called. In case of streamper="replicate"
, the function only checks
the availability of the rsprng
package on nodes but no initialization will be done at this point.
If the
"RNGstream" type is used, then in case of
streamper="node"
the snow function clusterSetupRNGstream
is
called and in case of
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
performParalell
,
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.
## 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)