# Derivation of variance of normal distribution with gamma function

So I'm reading about the derivation of the variance for normal distribution and I don't understand the following derivation with the use of gamma function. So, if I continue this derivation the integral becomes

$$2\int_{-\infty}^\infty ue^{-u}du\$$

which is clearly not gamma function (in gamma function integral goes from 0 to infinity). How can I solve this integral?

• You obviously made a mistake since the final integral does not exist. – Xi'an Feb 18 '18 at 12:56
• Show the steps of how you substituted $u=z^2/2$ and got rid of that pesky $\frac{1}{\sqrt{2\pi}}$. – Dilip Sarwate Feb 18 '18 at 13:17
• I didn't get rid of $1/\sqrt{2\pi}$, I copied only the integral since I'm interested only in it. – hippocampus Feb 18 '18 at 13:20
• Since $z^2$ is never negative, the integral you obtain--which includes all negative numbers--obviously is incorrect. – whuber Feb 18 '18 at 14:36
• @whuber I find it interesting that the variance of a normal distribution is obtained this way. This is the math of statistics, and, let we forget, without the math, stats would be useless, and new stats impossible. So, I voted to reopen, and finally got through to the end of the proof, below. – Carl Feb 18 '18 at 16:11

Note that as $z^2=(-z)^2$ then $$\dfrac{\sigma^2}{\sqrt{2\pi}}\int_{-\infty}^\infty z^2e^{-z^2/2}dz=2\dfrac{\sigma^2}{\sqrt{2\pi}}\int_{0}^\infty z^2e^{-z^2/2}dz\,,$$ that is, as the mean is $z=0$, the function is symmetric around the $z=0$ axis, and the twice the $[0,\infty)$ area is the $(-\infty,\infty)$ area.
Now let $u=z^2/2$, then $du=zdz$ and $dz=\dfrac{du}{\sqrt{2u}}$ and
$$2\dfrac{\sigma^2}{\sqrt{2\pi}}\int_{0}^\infty z^2e^{-z^2/2}dz\rightarrow2\dfrac{\sigma^2}{\sqrt{\pi}}\int_{0}^\infty u^{1/2}e^{-u}du\,.$$
Finally, $\Gamma(z) = \int_0^\infty x^{z-1} e^{-x}\,dx$, thus our integral can be rewritten as $$2\dfrac{\sigma^2}{\sqrt{\pi}}\Gamma\left(\dfrac{3}{2}\right)=\sigma ^2\,\,.$$