# Trying to Understand $E[X^2]$ for Gamma Distribution

I am trying to understand the following for the gamma distribution:

$$E[X^2] = \frac{ \alpha(\alpha+1)}{\lambda^2}$$

I've been looking at the reasoning for $E[X]$ to make sense of what could be happening, for instance:

$$E[X] = \int_{0}^{\infty}\frac{\lambda^\alpha}{\Gamma(\alpha)}x\cdot x^{\alpha-1}e^{-\lambda x}dx$$ $$=\frac{\lambda^\alpha}{\Gamma(\alpha)}\int_{0}^{\infty}x^{\alpha-1+1}e^{-\lambda x}dx$$ $$=\frac{\lambda^\alpha}{\Gamma(\alpha)}\cdot \frac{\Gamma(\alpha+1)}{\lambda^{\alpha+1}} = \frac{\alpha}{\lambda}$$

I can't make sense of what is happening to the second line where the integral drops out to become $$\int_{0}^{\infty}x^{\alpha-1+1}e^{-\lambda x}dx =\frac{\Gamma(\alpha+1)}{\lambda^{\alpha+1}}$$ I figure understanding this point would help with understanding the reasoning behind $E[X^2]$.

Thank you!

• suggest you check the definition of a gamma function. – John Polcari Jul 19 '18 at 13:25
• It's also the laplace transform of the function $f(t)=t^\alpha$ – Aryadeva Jul 19 '18 at 13:36

The gamma function is defined as $$\Gamma(t)=\int_0^\infty x^{t-1}e^{-x}\,dx$$ so let $u=\lambda x$ and $t=\alpha+1$.
$$E[X] = \int_{0}^{\infty}\frac{\lambda^\alpha}{\Gamma(\alpha)}x\cdot x^{\alpha-1}e^{-\lambda x}dx$$ $$=\frac{\lambda^\alpha}{\Gamma(\alpha)}\int_{0}^{\infty}x^{\alpha-1+1}e^{-\lambda x}dx = \frac{\lambda^\alpha}{\Gamma(\alpha)} \frac{\lambda^{a+1}\Gamma(a+1)}{\lambda^{a+1}\Gamma(a+1)}\int_{0}^{\infty}x^{\alpha-1+1}e^{-\lambda x}dx =$$ $$=\frac{\lambda^\alpha}{\Gamma(\alpha)}\cdot \frac{\Gamma(\alpha+1)}{\lambda^{\alpha+1}} \int_0^{\infty} \frac{1}{\Gamma(a+1)} (\lambda x) ^{a+1} e^{-\lambda x}\frac{dx}{x} = \frac{\lambda^\alpha}{\Gamma(\alpha)}\cdot \frac{\Gamma(\alpha+1)}{\lambda^{\alpha+1}} \times 1 = \frac{a}{\lambda}$$ because $f(x) = \frac{1}{\Gamma(a+1)} (\lambda x) ^{a+1} e^{-\lambda x}\frac{1}{x}$ is a PDF of $X \sim Gamma(a+1, \lambda)$