[R-sig-hpc] parallel random numbers: set.seed(i), rsprng, rlecuyer, ??

A.J. Rossini blindglobe at gmail.com
Thu Jun 17 16:13:01 CEST 2010


On Thu, Jun 17, 2010 at 3:57 PM, Dirk Eddelbuettel <edd at debian.org> wrote:
>
> It is a genuine issue, but it is also taken care of automagically if you use
> the snow package.  See ?clusterSetupRNG:
>
> snow-rand                 package:snow                 R Documentation
>
> Uniform Random Number Generation in SNOW Clusters
>
> Description:
>
>     Initialize independent uniform random number streams to be used in
>     a SNOW cluster. It uses either the L'Ecuyer's random number
>     generator (package rlecuyer required) or the SPRNG generator
>     (package rsprng required).
>
> Usage:
>
>     clusterSetupRNG (cl, type = "RNGstream", ...)
>
>     clusterSetupRNGstream (cl, seed=rep(12345,6), ...)
>     clusterSetupSPRNG (cl, seed = round(2^32 * runif(1)),
>                        prngkind = "default", para = 0, ...)
> [...]
>
>
> The "if in doubt, try standing on the shoulder of giants" approach ...
>
>

my work address was cc'd, but I'm subscribed via my personal address.
 So my first response is queued up for moderator approval.

Basically:

SNOW handles it for you, as Dirk said.

Use Rlecuyer and NOT rsprng, as Raphael said.  sprng's justifications
for the 2.0 version seemed a bit dicey, L'Ecuyer's approach appears to
be better supported theoretically.

The "lots of random seeds that I pick approach" will work most of the
time -- but you will NEVER know when it fails (and you end up with a
few correlated or identical streams or sub-streams), so unless you
like playing fast and loose with your results, don't.
So in practice it usually works.  Fine if "usually" is good enough for you.

Ahh.  Enough real thinking for today.  Back to being a pointy and
air-headed boss for a new group.
(hiring soon to support Molecular Diagnostics).

best,
-tony

blindglobe at gmail.com
Muttenz, Switzerland.
"Commit early,commit often, and commit in a repository from which we
can easily roll-back your mistakes" (AJR, 4Jan05).

Drink Coffee:  Do stupid things faster with more energy!



More information about the R-sig-hpc mailing list