# Problem of differentiation in deriving the moment (Mean and Variance) of Gamma Distribution from MGF

I was trying to find the mean and variance of Gamma Distribution through MGF.

Luckily I've successfully to find $$M_X(t)=\int_0^\infty e^{tx} \frac{\lambda^\alpha x^{\alpha-1}}{\Gamma(\alpha)}e^{-\lambda x} \, dx = \lambda^\alpha(\lambda-t)^{-\alpha}$$

To get the mean which is the first moment, I know that I've to differentiate it.

$$M_X(t)=\lambda^\alpha(\lambda-t)^{-\alpha}$$

But I don't know how to differentiate it. Hope someone can point it out.

## 1 Answer

$$M_X(t) = (1 - t/\lambda)^{-\alpha},$$ so $$M'_X(t) = (-\alpha)(-1/\lambda)(1 - t/\lambda)^{-\alpha-1} = \frac{\alpha}{\lambda}(1 - t/\lambda)^{-\alpha-1}$$ by the chain rule. Then evaluating at $t=0$, we get $$M'_X(0) = \frac{\alpha}{\lambda}.$$ It is not difficult to see that $$M^{(r)}_X(t) = \frac{\alpha(\alpha+1)\cdots(\alpha+r-1)}{\lambda^r}(1-t/\lambda)^{-\alpha-r},$$ and in particular $$M^{(r)}_X(0) = \frac{\alpha(\alpha+1)\cdots(\alpha+r-1)}{\lambda^r} = \binom{\alpha+r-1}{r} \frac{r!}{\lambda^r}.$$ This gives the second moment $$\operatorname{E}[X^2] = \frac{\alpha(\alpha+1)}{\lambda^2},$$ and the variance follows easily.