# PDF for Gamma Distribution not what I expect [closed]

I have plotted the the PDF for a Gamma Distribution with various parameters (e.g. 3 and 5) using Manipulate:

Manipulate[
Plot[PDF[GammaDistribution[α, β], x], {x, -1, 20}],
{ α, -1, 8}, { β, -1, 6}]


However, the plots that I get are quite different to what I get using R and which I know to be correct. For example the PDF with $\Gamma(3,5)$ should have a peak in the curve at 0.4. The plot that Mathematica produces gives me a peak that is more like 11.

Does anybody have any ideas what I am doing wrong here?

• Any reason why you are not using the built-in GammaDistribution ? – Sektor Feb 24 '14 at 13:50
• You're using a shape/scale parametrization (and getting the correct result). Most likely R is using a shape/rate parametrization. Try alpha = 3, beta = 1/5 to get the PDF you are looking for. – Simon Woods Feb 24 '14 at 14:13
• As Simon said, you should verify R's implementations of Gamma and make sure that the arguments are same. There's an example where the implementation differed between MATLAB and Mathematica, so it's not uncommon. – rm -rf Feb 24 '14 at 14:22
• Are you by any chance the same person who asked this question? If not, take a look at the answers there. – Szabolcs Feb 24 '14 at 14:24

In Mathematica, the PDF of a GammaDistribution[a,b] is proportional to $$x^{a-1} e^{-\frac{x}{b}},$$ as described in the documentation.
In R, dgamma(x, shape=a, rate=r) is a PDF proportional to
$$x^{a-1} e^{-r x},$$
R's rate $r$ is the same as Mathematica's $1/b$. Just make sure you use these parameters correctly. Or use the scale parameter of R, as in dgamma(x, shape=a, scale=b).