The moment-generating function of the gamma distribution is
How do we get there? First let’s combine the two exponential terms and move the gamma fraction out of the integral:
Multiply
Now we’re ready to do so substitution in the integral. Let
If re-write everything inside the integral with exponents we can do some cancellation and make this integral more attractive:
Using the rules of exponents we see that
Using the rules of exponents again we see that
Now notice we can cancel out the two
The integral is now the gamma function:
Cancel out the
If we take the derivative of this function and evaluate at 0 we get the mean of the gamma distribution:
Recall that
If we take the second derivative of the moment-generating function and evaluate at 0, we get the second moment about the origin which we can use to find the variance:
Now find the variance:
Going back to our example with
Plugging the mean and standard deviation into the dgamma function in R, we can plot this particular gamma distribution:
xval <- seq(0,30, by = 0.01) ga.4 <- dgamma(xval, shape=4, scale=2) plot(xval,ga.4,col=1, type = "l", ylab="f(x)", xlab="x") title(main="Gamma Distribution, scale = 2, shape = 4")