# How to calculate the expected value of a standard normal distribution?

I would like to learn how to calculate the expected value of a continuous random variable. It appears that the expected value is $$E[X] = \int_{-\infty}^{\infty} xf(x)\mathrm{d}x$$ where $f(x)$ is the probability density function of $X$.

Suppose the probability density function of $X$ is $$f(x) = \frac{1}{\sqrt{2\pi}}e^{\frac{-x^{2}}{2}}$$ which is the density of the standard normal distribution.

So, I would first plug in the PDF and get $$E[X] = \int_{-\infty}^{\infty} x\frac{1}{\sqrt{2\pi}}e^{\frac{-x^{2}}{2}}\mathrm{d}x$$ which is a rather messy looking equation. The constant $\displaystyle\frac{1}{\sqrt{2\pi}}$ can be moved outside the integral, giving $$E[X] = \frac{1}{\sqrt{2\pi}}\int_{-\infty}^{\infty} xe^{\frac{-x^{2}}{2}}\mathrm{d}x.$$

I get stuck here. How do I calculate integral? Am I doing this correctly this far? Is the simplest way to get the expected value?

• your question title is misleading. You are in fact trying to calculate the expected value of a standard normal random variable. You can also calculate the expected value of a function of a RV. I would rather put in the title: "How to calculate the expected value of a standard normal distribution." Or "How to calculate the expected value of a continuous random variable." – Gumeo Oct 13 '15 at 9:05
• @GuðmundurEinarsson corrected. – mmh Oct 13 '15 at 11:07
• "I get stuck here. How do I calculate integral?" Find the derivative of $-e^{-\frac{x^2}{2}}$. (No, I am not being facetious and suggesting needless busywork to you; I am deadly serious; Just Do It!). Then stare very hard at the derivative you have found. – Dilip Sarwate Dec 3 '15 at 5:19

$$E[X] = \frac{1}{\sqrt{2\pi}}\int_{-\infty}^{\infty} xe^{\displaystyle\frac{-x^{2}}{2}}\mathrm{d}x\\=-\frac{1}{\sqrt{2\pi}}\int_{-\infty}^{\infty}e^{-x^2/2}d(-\frac{x^2}{2})\\=-\frac{1}{\sqrt{2\pi}}e^{-x^2/2}\mid_{-\infty}^{\infty}\\=0$$.

Or you can directly use the fact that $xe^{-x^2/2}$ is an odd function and the limits of the integral are symmetry.

• The symmetry argument only works if both halves are themselves convergent. – Glen_b Oct 13 '15 at 10:50
• Could you explain what happens on the second row? – mmh Oct 13 '15 at 11:12
• Glen's comment is correct if it is not convergent then change-of-variables will not work – Deep North Oct 13 '15 at 11:23
• The second row is equal to the first row since $d(-\frac{x^2}{2})=-xdx$ also note the negative sign at the beginning. Then you can think of change of variable for integration, then you change it back since the limits did not change. Or you can use integrate by parts. And remember $\int_{a}^{b}e^y dy=e^y\mid_{a}^{b}$ – Deep North Oct 13 '15 at 11:37
• To use symmetry to get the mean you need to know that $\int_0^\infty xf(x) dx$ converges - it does for this case, but more generally you can't assume it. For example, the symmetry argument would say that the mean of the standard Cauchy is 0, but it doesn't have one. – Glen_b Dec 3 '15 at 1:23

Since you want to learn methods for computing expectations, and you wish to know some simple ways, you will enjoy using the moment generating function (mgf)

$$\phi(t) = E[e^{tX}].$$

The method works especially well when the distribution function or its density are given as exponentials themselves. In this case, you don't actually have to do any integration after you observe

$$t^2/2 -\left(x - t\right)^2/2 = t^2/2 + (-x^2/2 + tx - t^2/2) = -x^2/2 + tx,$$

because, writing the standard normal density function at $x$ as $C e^{-x^2/2}$ (for a constant $C$ whose value you will not need to know), this permits you to rewrite its mgf as

$$\phi(t) = C\int_\mathbb{R} e^{tx} e^{-x^2/2} dx = C\int_\mathbb{R} e^{-x^2/2 + tx} dx = e^{t^2/2}C\int_\mathbb{R} e^{-(x-t)^2/2} dx .$$

On the right hand side, following the $e^{t^2/2}$ term, you will recognize the integral of the total probability of a Normal distribution with mean $t$ and unit variance, which therefore is $1$. Consequently

$$\phi(t) = e^{t^2/2}.$$

Because the Normal density gets small at large values so rapidly, there are no convergence issues regardless of the value of $t$. $\phi$ is recognizably analytic at $0$, meaning it equals its MacLaurin series

$$\phi(t) = e^{t^2/2} = 1 + (t^2/2) + \frac{1}{2} \left(t^2/2\right)^2 + \cdots + \frac{1}{k!}\left(t^2/2\right)^k + \cdots.$$

However, since $e^{tX}$ converges absolutely for all values of $tX$, we also may write

$$E[e^{tX}] = E\left[1 + tX + \frac{1}{2}(tX)^2 + \cdots + \frac{1}{n!}(tX)^n + \cdots\right] \\ = 1 + E[X]t + \frac{1}{2}E[X^2]t^2 + \cdots + \frac{1}{n!}E[X^n]t^n + \cdots.$$

Two convergent power series can be equal only if they are equal term by term, whence (comparing the terms involving $t^{2k} = t^n$)

$$\frac{1}{(2k)!}E[X^{2k}]t^{2k} = \frac{1}{k!}(t^2/2)^k = \frac{1}{2^kk!} t^{2k},$$

implying

$$E[X^{2k}] = \frac{(2k)!}{2^kk!},\ k = 0, 1, 2, \ldots$$

(and all expectations of odd powers of $X$ are zero). For practically no effort you have obtained the expectations of all positive integral powers of $X$ at once.

Variations of this technique can work just as nicely in some cases, such as $E[1/(1-tX)] = E[1 + tX + (tX)^2 + \cdots + (tX)^n + \cdots]$, provided the range of $X$ is suitably limited. The mgf (and its close relative the characteristic function $E[e^{itX}]$) are so generally useful, though, that you will find them given in tables of distributional properties, such as in the Wikipedia entry on the Normal distribution.