[Rcpp-devel] Setting the R random seed from Rcpp
szehnder at uni-bonn.de
Fri Jun 7 16:35:43 CEST 2013
I do not know what you really want to do, but if you want to replicate results, you could do the following in Rcpp before running the RNG:
Rcpp::Function setSeed = baseEnv["set.seed"];
setSeed(0); //any other number would do it here
On Jun 7, 2013, at 4:22 PM, Matteo Fasiolo <matteo.fasiolo at gmail.com> wrote:
> Dear Rcpp experts,
> I would like to be able to store the R random seed from a Rcpp
> function and then reset it. In other words I would like to replicate
> the following code in Rcpp:
> savedSeed <- .Random.seed
> x <- Rfunction(parameters1);
> .Random.seed <- savedSeed
> x1 <- Rfunction(parameters2);
> where Rfunction simulates some random numbers and uses them
> but with different parameter values.
> Is it possible to do something similar in Rcpp?
> Probably using GetRNGstate() and PutRNGstate()?
> Rcpp-devel mailing list
> Rcpp-devel at lists.r-forge.r-project.org
More information about the Rcpp-devel