[Rcpp-devel] Setting the R random seed from Rcpp

Matteo Fasiolo matteo.fasiolo at gmail.com
Fri Jun 7 18:24:32 CEST 2013


Dirk,

 you are right, intuitively I see that the way I'm doing things doesn't
seem very save. The motivation behind my experimentation is that
I'm trying to move things from R to C++ in order to avoid that segfault
problem that we observed a couple of weeks ago.
Probably I'm clinging a bit too much to R RNGs, but maybe I should
switch to a C++ RNG. The problem is complicated also by the fact
that I'm using the parallel package, so I have to careful about what I do!



On Fri, Jun 7, 2013 at 5:12 PM, Dirk Eddelbuettel <edd at debian.org> wrote:

>
> Matteo,
>
> Maybe you may need to figure this out in plain C(++) code based on the
> Writing R Extensions manual first.  R makes an assumption about keeping the
> RNGs in a good state, I am not entirely sure if you actually can do what
> you
> want to do. Just because you can call an R function from Rcpp does not mean
> it will do the right thing.
>
> Maybe what you want is more easily done with the RNGs from C++ (esp C++11),
> Boost, ... or something different from R.   It may work, but we are
> (currently) simply not set up for it.
>
> The model is to call set.seed(somenumber) from R before going to C++, and
> being assured that a) you get the same stream in C++ as you would in R as
> well as b) that you can continue fine in R once you are back.
>
> What you want is a little different.  It may well be supported, but maybe
> just not (yet ?) by us. Or it may not be supported.  Please keep working at
> it, this would be useful to sort this out.
>
> Just because you can get the integer seed via R from C++ does yet mean that
> the generator is a sane state.  Just saying...
>
> Dirk
>
> --
> Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20130607/061cfa8d/attachment.html>


More information about the Rcpp-devel mailing list