[Rcpp-devel] R random numbers vs c++
Davor Cubranic
cubranic at stat.ubc.ca
Thu Mar 22 16:20:54 CET 2012
On 2012-03-22, at 5:41 AM, Glenn Lawyer wrote:
> Is there a reason to prefer Rcpp::runif over the c++ rand() for, say, accepting a state in a Markov chain simulation? Is one more random than another? faster?
I'd use the R random generator so your C++ code is in sync with R in terms of seeds and random sequences. For instance, if you're running your simulation in parallel on multiple machines or cores, you can use one of the RNG's designed specifically to avoid correlations between individual instances, such as SPRNG or RNGstream.
Davor
More information about the Rcpp-devel
mailing list