This question is twofold. I am translating an R script into C++ that uses the L\'Ecuyer combined multiple recursive generator (CMRG) as it\'s engine (in particular, MRG32k3a), w
The first question is thus, where can I find the documentation on the MRG32k3a implementation in R that specifies these parameters?
I would use the source: https://github.com/wch/r-source/blob/5a156a0865362bb8381dcd69ac335f5174a4f60c/src/main/RNG.c#L143
The problem is I have no idea how this is done and I can't seem to find any information anywhere (aside from knowing that engines are classes).
The requirements for a RandomNumberEngine can be found here:
https://en.cppreference.com/w/cpp/named_req/RandomNumberEngine
Although it is sufficient to fulfill UniformRandomBitGenerator if you want to use uniform_real_distribution
:
Expression Return type Requirements
G::result_type T T is an unsigned integer type
G::min() T Returns the smallest value that G's operator()
may return. The value is strictly less than
G::max().
G::max() T Returns the largest value that G's operator() may
return. The value is strictly greater than
G::min()
g() T Returns a value in the closed interval [G::min(),
G::max()]. Has amortized constant complexity.
Main problem is that MRG32k3a is meant to return a floating point number in (0,1), while a C++ UniformRandomBitGenerator returns an integer type. Why do you want to integrate with the
header?
Additional difficulties you would have to take into account:
Alternatives would include using R source code directly without integration with the
header or link to libR
.