I would like to find $E[|X-\mu|]$ when $X$ is $N(\mu, \sigma^2)$.
I think I need to evaluate the integral:
$$E[|X-\mu|]=\int_{\mathbb{R}} |x-\mu| \frac{1}{\sigma\sqrt{2 \pi}} e^{-\frac{1}{2} \left( \frac{x-\mu}{\sigma} \right)^2} dx$$
This is the same as the following since $e^u>0$
$$=\int_{\mathbb{R}} \left|(x-\mu) \frac{1}{\sigma\sqrt{2 \pi}}e^{-\frac{1}{2} \left( \frac{x-\mu}{\sigma} \right)^2}\right| \, dx$$
So, I need to find the solution to:
$$(x-\mu) \frac{1}{\sigma\sqrt{2 \pi}}e^{-\frac{1}{2}\left( \frac{x-\mu}{\sigma} \right)^2}=0$$
To determine where to break the integral. The above is only zero where $x=\mu$. So I break it at $\mu$
$$E[|X-\mu|]=\int_{-\infty}^\mu \left|(x-\mu) \frac{1}{\sigma\sqrt{2 \pi}} e^{-\frac{1}{2} \left( \frac{x-\mu}{\sigma} \right)^2}\right| \, dx + \int_\mu^\infty \left|(x-\mu) \frac{1}{\sigma\sqrt{2 \pi}}e^{-\frac{1}{2}\left( \frac{x-\mu}{\sigma} \right)^2}\right| \, dx$$
If $x \in (-\infty, \mu)$ then $x-\mu<0$ so we can multiply the first integral by $-1$ and remove the absolute value bars.
$$E[|X-\mu|]=-\int_{-\infty}^\mu (x-\mu) \frac{1}{\sigma\sqrt{2 \pi}} e^{-\frac{1}{2} \left( \frac{x-\mu}{\sigma} \right)^2} \, dx + \int_\mu^\infty (x-\mu) \frac{1}{\sigma\sqrt{2 \pi}}e^{-\frac{1}{2}\left( \frac{x-\mu} \sigma \right)^2} \, dx$$
now we have:
$$=-\int_{-\infty}^{\mu} \frac{1}{\sigma\sqrt{2 \pi}}xe^{-\frac{1}{2}\left( \frac{x-\mu}{\sigma} \right)^2}dx +\mu\int_{-\infty}^{\mu} \frac{1}{\sigma\sqrt{2 \pi}}e^{-\frac{1}{2}\left( \frac{x-\mu}{\sigma} \right)^2}dx +{} $$
$$\int_\mu^\infty \frac{1}{\sigma\sqrt{2 \pi}}xe^{-\frac{1}{2}\left( \frac{x-\mu}{\sigma} \right)^2} \, dx -\mu\int_\mu^\infty \frac{1}{\sigma\sqrt{2 \pi}}e^{-\frac{1}{2}\left( \frac{x-\mu}{\sigma} \right)^2} \, dx$$
I'm not certain how to deal with these integrals? Any hints?
$X-\mu\sim N(0,\sigma^2)$. thus $E(|X-\mu|)=\int_R|x|\frac{1}{\sqrt{2\pi}\sigma}e^{-x^2/2\sigma^2}dx=2\int^\infty_0 x\frac{1}{\sqrt{2\pi}\sigma}e^{-x^2/2\sigma^2}dx$. The antiderivative is $\frac{-2\sigma^2}{\sqrt{2\pi}}e^{-x^2/2\sigma^2}$. Thus the answer is $2\sigma^2/\sqrt{2\pi}$