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

Dirk Eddelbuettel edd at debian.org
Fri Jun 7 18:12:18 CEST 2013


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 Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com

More information about the Rcpp-devel mailing list