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?
 A: You are almost there,
follow your last step:
$$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 symmetric about $x=0$.
A: 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.
A: A more straightforward and general way to calculate these kinds of integrals is by changing of variable:
Suppose your normal distribution has mean $\mu$ and variance $\sigma^2$: $\mathcal{N(\mu, \sigma^2)}$
$$
E(x) = \frac{1}{\sigma\sqrt{2 \pi}} \int x \exp(-\frac{(x-\mu)^2}{2\sigma^2})dx
$$
now by changing the variable $y = \frac{x-\mu}{\sigma}$ and $\frac{dy}{dx}=\frac{1}{\sigma} \rightarrow dx = \sigma dy$.
$$
E(x) = \frac{\sigma}{\sigma\sqrt{2 \pi}} \int (\sigma y + \mu) \exp(-\frac{y^2}{2})dy = \\
\frac{\sigma}{\sigma\sqrt{2 \pi}} \left[ \int \sigma y e^{-\frac{y^2}{2}} dy 
 + \mu \int e^{-\frac{y^2}{2}} dy \right]
$$
The first integral is an odd integral since $y$ is an odd function and $e^{-\frac{y^2}{2}}$ is an even function which results in an odd function with symmetric integral boundaries and is zero. The second integral itself has an answer of $2\pi$.
$$
E(x) = \frac{\mu \sigma \sqrt{2 \pi}}{\sigma \sqrt{2 \pi}} = \mu
$$
In your case since your distribution has a mean of zero by your definition the answer is
$E(x) = 0$.
