Dear all,

I believe it's the second time I just realized that Rcpp::rgamma() behaves
differently than to R's rgamma() when called without named arguments:

********** BEGIN code.R **********

library(Rcpp)

cppFunction('
    SEXP rgamma2(const int n, const double a, const double b) {
        RNGScope scope;
        return Rcpp::rgamma(n, a, b);
    }
')

set.seed(123);
print(rgamma(1, 2, 3));

set.seed(123);
print(rgamma2(1L, 2, 3));

set.seed(123);
print(rgamma2(1L, 2, 1/3));

**********  END  code.R **********

yields:

[1] 0.2973645
[1] 2.676281
[1] 0.2973645

Maybe this is worth a tiny note in e.g. the "Rcpp syntactic sugar" vignette?
Might save me (and possibly others) from realizing a third time.

Best and thanks,
Gregor
_______________________________________________
Rcpp-devel mailing list
[email protected]
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel

Reply via email to