# 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?

## closed as off-topic by user9660, MarcoB, RunnyKine, LLlAMnYP, m_goldbergMay 3 '16 at 14:13

This question appears to be off-topic. The users who voted to close gave this specific reason:

• "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – Community, MarcoB, RunnyKine, LLlAMnYP, m_goldberg
If this question can be reworded to fit the rules in the help center, please edit the question.

• 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},$$

again as described in the documentation.

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).

For many such functions there's no universal agreement on what is the meaning of the first, second, etc. parameters. Always be sure to look up the notational conventions used by the book you are reading or the software you are using.