[Rd] portable parallel seeds project: request for critiques

Petr Savicky savicky at cs.cas.cz
Fri Mar 2 14:51:30 CET 2012


On Fri, Mar 02, 2012 at 01:36:34PM +0100, Karl Forner wrote:
> Thanks for your quick reply.
> 
> About the rngSetSeed package: is it usable at c/c++ level ?

Not directly. The rngSetSeed package is meant to provide an R-level
alternative to set.seed() for Mersenne-Twister with a better guarantee
that different seeds provide unrelated streams. In particular, with
rngSetSeed, it should be safe to reseed quite often, for example
in each iteration of a loop like

  for (i in 1:n) {
      setVectorSeed(c(base.seed, i))
      # some code
  }

Otherwise everything remains the same as with set.seed(). In order
to maintain several streams, one has to maintain copies of .Random.seed
and use them, when required.

> Hmm I had not paid attention to the last paragraph:
> 
> > The seeding procedure used in the
> > present software use*s a separate random number* generator of a different
> > design in order to
> > avoid any interference. An extra feature is the RandomInitByArray function
> > which makes
> > it possible to initialize the random number generator with multiple seeds.
> > We can make sure
> > that the streams have different starting points by using the thread id as
> > one of the seeds.
> >
> 
> So it means that I am already using this solution ! (in the RcppRandomSFTM,
> see other post).
> and that I should be reasonably safe.

If RcppRandomSFTM uses the initialization for SFMT provided by the
authors of SFMT, then you should be reasonably safe. I do not know
exactly the SFMT initializations, but for the original Mersenne-Twister,
the initializations from 2002, both the single number seed and a vector
seed avoid known problems with the previous initializations. It should
be pointed out, however, that the initialization by array from 2002 is
more careful than the single number initialization, So, it is better to
use the array initialization even for a single number seed.

Petr Savicky.



More information about the R-devel mailing list