# [Rcpp-devel] pb rgamma?

Dirk Eddelbuettel edd at debian.org
Fri Apr 10 14:42:11 CEST 2015

```On 10 April 2015 at 14:23, Serguei Sokol wrote:
| Le 10/04/2015 12:41, Sean O'Riordain a écrit :
| > The R definition of the gamma distribution is the "inverse-rate", refer https://stat.ethz.ch/R-manual/R-patched/library/stats/html/GammaDist.html
| > Could the Rcpp gamma distribution be using the standard "rate" parameterization as seen on the Wikipedia page http://en.wikipedia.org/wiki/Gamma_distribution?
| > Nb. the "inverse-rate" parameterization is simply a substitution of newrate=1/rate...
| >
| >  > set.seed(7)
| >  > rgamma(1,3,1/4)
| > [1] 29.69732
| Thanks Sean. However, I am a little bit puzzled by
| a decision to implement a different algorithm in Rcpp
| than in R. Isn't it contradictory with the spirit of sugar?

Rcpp does exactly what the __C API for R__ does. Which is also different from
what you get at the command-line. See

edd at max:~\$ grep "[pqrd]gamma.*double" /usr/share/R/include/Rmath.h
double  dgamma(double, double, double, int);
double  pgamma(double, double, double, int, int);
double  qgamma(double, double, double, int, int);
double  rgamma(double, double);
edd at max:~\$

and see this comment in Writing R Extensions:

Note that these argument sequences are (apart from the names and that
'rnorm' has no N) mainly the same as the corresponding R functions of
the same name, so the documentation of the R functions can be used.
Note that the exponential and gamma distributions are parametrized by
'scale' rather than 'rate'.

All this has been discussed before.  Please use your favourite search engine
targeted at the list archive.

Dirk

--
http://dirk.eddelbuettel.com | @eddelbuettel | edd at debian.org
```