Re: [R-pkg-devel] R-extension requirement about third-party random number generators (RNG)

2024-09-27 Thread Kasper Daniel Hansen
John, Your post does not have many details but why do you think that instantiating 4 instances of the Mersenne Twister will keep the streams independent? It is possible to get independent streams, but it will need more work. Best, Kasper On Fri, Sep 27, 2024 at 11:17 AM Dirk Eddelbuettel wrote:

Re: [R-pkg-devel] R-extension requirement about third-party random number generators (RNG)

2024-09-27 Thread Jeff Newmiller via R-package-devel
You mention that you did not like putting the rstream in the user API but there is nothing forcing you to have the user call your cpp function directly... there are lots of packages that use R glue functions as the API. I have not dug into Dirk's code, but having the native R seed management is

Re: [R-pkg-devel] R-extension requirement about third-party random number generators (RNG)

2024-09-27 Thread Dirk Eddelbuettel
On 27 September 2024 at 16:58, John Clarke wrote: | [...] -- the RNG state management strategy appears almost 'magical' to me | especially inside RCPP. It is possible, I just don't understand how to use it. See Section 6.3 of WRE: The pair of GetRNGstate() and PutRNGstate() is all there is in te

Re: [R-pkg-devel] R-extension requirement about third-party random number generators (RNG)

2024-09-27 Thread John Clarke
Hi Dirk, Thanks very much for your thoughtful reply. This is a relief for me as my 'solution' for replacing the existing RNG in my C++ was convoluted and I couldn't see the advantage in doing so. Thank you for the search tip -- that is really helpful and I did not know that there was this kind of

Re: [R-pkg-devel] R-extension requirement about third-party random number generators (RNG)

2024-09-27 Thread Dirk Eddelbuettel
Hi John, I think you are reading the text too literally. The intent of WRE is to ensure that standard use of a RNG in an extension package uses the RNGs that come with R (which includes an updated mersenne twister algorithm) so that users are not "surprised". It explicitly mentions the problem

[R-pkg-devel] R-extension requirement about third-party random number generators (RNG)

2024-09-27 Thread John Clarke
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