Expectation of an absolute value of a normal random variate Given that a random variable $X$ is a normally distributed variable with mean $\mu$ and variance $\sigma^2$. Why exactly is:
$$\mathbb{E}[|X|] = \mathbb{E}[X\mid X>0]P(X>0) - \mathbb{E}[X\mid X<0]P(X<0)$$
Because we have that:
$$\mathbb{E}[X\mid X>0] = \frac{\int_0^\infty xf_X(x)\,dx}{P(X>0)}$$
Therefore my definition immediately above must be incorrect?
Because if it is not we have that:
$$\mathbb{E}[|X|] = \int_0^\infty xf_X(x)\,dx - \int_{-\infty}^0 xf_X(x)\,dx$$
and where does the minus there come from anyway, and why?
 A: \begin{align}
\operatorname{E}(|X|) & = \int_{-\infty}^\infty |x| f_X(x)\,dx \\[10pt]
& = \int_{-\infty}^\infty |x| \frac 1 {\sqrt{2\pi}} e^{-x^2/2} \, dx \tag a \\[10pt]
& = 2 \int_0^\infty x \frac 1 {\sqrt{2\pi}} e^{-x^2/2} \,dx & & \left( \begin{array}{l} \text{since the function} \\  \text{in line (a) is even,} \end{array} \right) \\[10pt]
& = \frac 2 {\sqrt{2\pi}} \int_0^\infty e^{-x^2/2} \Big(x\,dx\Big) & & \text{HINT!} \\[10pt]
& = \frac 2 {\sqrt{2\pi}} \int_0^\infty e^{-u} \,du & & \left( \begin{array}{l} \text{So the hint wasn't needed} \\  \text{since I gave you this.} \end{array} \right) \\[10pt]
& = \text{what?}
\end{align}
When $x=0$ then $u=0$ and as $x\to\infty$ then $u\to\infty$, so the bounds of integration do not change when the substitution is done.
Can you do the rest?
A: In general if $\mathbb{E}\left|X\right|<\infty$ then:
$$\mathbb{E}\left|X\right|=$$$$\mathbb{E}\left(\left|X\right|\mid X>0\right)P\left(X>0\right)+\mathbb{E}\left(\left|X\right|\mid X=0\right)P\left(X=0\right)+\mathbb{E}\left(\left|X\right|\mid X<0\right)P\left(X<0\right)=$$$$\mathbb{E}\left(\left|X\right|\mid X>0\right)P\left(X>0\right)+\mathbb{E}\left(\left|X\right|\mid X<0\right)P\left(X<0\right)$$
Also:


*

*$\left|X\right|=X$ under condition $X>0$

*$\left|X\right|=-X$ under condition $X<0$ .


So we end up with:
$$\mathbb{E}\left|X\right|=$$$$\mathbb{E}\left(X\mid X>0\right)P\left(X>0\right)+\mathbb{E}\left(-X\mid X<0\right)P\left(X<0\right)=$$$$\mathbb{E}\left(X\mid X>0\right)P\left(X>0\right)-\mathbb{E}\left(X\mid X<0\right)P\left(X<0\right)$$
