Hi folks, Reference from the manual:
- Nor should the C++11 random number library be used nor any other third-party random number generators such as those in GSL.” I am working at wrapping an existing statistical model with RCPP so it can be used in R. The model is written in C++ and uses the well-known Mersenne Twister RNG C++ class. We instantiate 4 instances of the RNG to keep the random variates independent. I understand from the r-release manual <https://cran.r-project.org/doc/manuals/r-release/R-exts.html#Writing-portable-packages-1> that we should not use third-party RNGs and rather use R's interfaces to R's internal random number generator. If this is a correct reading of the requirement for an R package/extension, it will add quite a bit of complexity to the wrapper because we'll have to probably pass in references to something like *rstream* objects to ensure the streams/substreams remain independent. I fear that it may also might negatively affect performance of the model because (if I understand correctly) we need to maintain the state of a single RNG engine and due to the nature of our model, we don't pre-generate all the RNGs but rather generate just a few before switching to another stream. This would mean get/setting the RNG state with every single draw unless substantial changes were made to batch generate the numbers a priori. Before we tackle this problem, I want to confirm that it is indeed forbidden to use the Mersenne Twister C++ class in a RCPP R package if we want to publish it on CRAN. Then, if it is a requirement, and assuming I want to use the *rstream* RNG package, how can I instantiate an rstream object in C++? I've succeeded at instantiating it in R and passing it through, but this isn't ideal because it breaks encapsulation/ease-of-use for the user. Thanks, -John [[alternative HTML version deleted]] ______________________________________________ R-package-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-package-devel