Reputation: 7474
When RNGScope scope
is needed when using Rcpp? In general, you need it when using C RNG functions. In some places you can read that it is not needed when using Rcpp, examples in Rcpp documentation use it, some examples by Dirk Eddelbuettel use it, while others do not like this one or this do not. So in the end I'm confused...
When exactly is it needed and when not? Does it make a difference if I use Rcpp::runif()
, R::runif()
, or R::unif_rand()
? I'm interested mostly in using Rcpp within R package rather then calling standalone code.
Upvotes: 1
Views: 303
Reputation: 368509
In short:
RNGScope
automates this for you as it is so darn useful (and generally inexpensive)RNGScope
(as you can see when you turn on verbose=TRUE
So in general you don't need to anything manual -- unless you go really old school and write all code directly, foregoing the glue provided by Rcpp.
And if you use Rcpp, it doesn't matter whether you use scalar interfaces from the R::
namespace or the vectorized Rcpp Sugar
onces via Rcpp::
. RNGScope
will be there for you.
Upvotes: 4