5

How to show:

$E(|X-a|) = \int_{-\infty}^a P(X < x) \, dx + \int_a^\infty P(X > x) \, dx$.

I have:

$$E(|X-a|) = \int |X-a| \, dP = \int_{\mathbb{R}} |x-a| P_X(dx) = \int_{(-\infty,a)} a-x P_X(dx) + \int_{(a,\infty)} x-a P_X(dx)$$

But I do not see where to go. And how do I get to the Riemann-Integral? It is just $E(|X|)<\infty$ known, but nothing about an density function (in this case I would know how to get to the Riemann integral).


$$E(|X-a|) = \int_{(0,\infty)} P(|X-a| > t) \lambda(dt) = \int_{(0,\infty)} P(\max(X-a,0)+\max(a-X,0) > t) \lambda(dt)$$

This gives, since the events are disjoint, and with Rieman-integrability:

$$E(|X-a|) = \int_0^{\infty} P(\max(X-a,0) > t) + P(\max(a-X,0) > t) dx$$

How to go on? Integral is linear, but I do not know how separating them would help..


Finally it is first proven that:

$E(|X|) = \int_{-\infty}^0 P(X < x) \, dx + \int_0^\infty P(X > x) \, dx$.

Now I want to conclude for $|X-a|$.

$E(|X-a|) = \int_{-\infty}^0 P(X-a < x) \, dx + \int_0^\infty P(X-a > x) \, dx$ $= \int_{-\infty}^0 P(X < x+a) \, dx + \int_0^\infty P(X > x+a) \, dx$ $= \int_{-\infty}^a P(X < x) \, dx + \int_a^\infty P(X > x) \, dx$

saz
  • 120,083

3 Answers3

3

I think it would be easier if we start from the formula $$\mathbb E(Y)=\int_0^{+\infty}\mathbb P\{Y>t\}\mathrm dt,$$ where $Y$ is a non-negative random variable.

Then notice that for a real number $x$, we have $|x|=\max\{x,0\}+\max\{0,-x\}$.

Making a substitution $u=x-a$ in the two integral in the RHS of the equality we want to prove, we notice that we can assume that $a=0$.

We thus have $$\mathbb E|X|=\mathbb E\max\{X,0\}+\mathbb E\max\{0,-X\}.$$ We have for $t>0$ $$\{\max\{X,0\}>t\}=\{X>t\}$$ and $$\{\max\{-X,0\}>t\}=\{X<-t\},$$ hence we get the result integrating.

Davide Giraudo
  • 172,925
2

Normally, for a positive variable, I think of $$ \mathrm{E}(Y)=-\int_0^\infty x\,\frac{\mathrm{d}}{\mathrm{d}x}P(Y\ge x)\,\mathrm{d}x $$ Since $-\frac{\mathrm{d}}{\mathrm{d}x}P(Y\ge x)$ is the probability density of $Y$ being near $x$. $P(Y\ge x)$ is monotonic decreasing and so it is differentiable almost everywhere. If $P(Y\ge x)$ is not differentiable everywhere, we can use the Riemann-Stieltjes Integral and define $$ \mathrm{E}(Y)=-\int_0^\infty x\,\mathrm{d}P(Y\ge x) $$

Integration by parts, which is valid for the Riemann-Stieltjes integral, yields $$ \mathrm{E}(Y)=-\lim_{x\to\infty}x\,P(Y\ge x)+\int_0^\infty P(Y\ge x)\,\mathrm{d}x $$ Summation by parts gives $$ \begin{align} \mathrm{E}(Y) &\ge\sum_{k=0}^\infty2^k\left(P(Y\ge2^k)-P(Y\ge2^{k+1})\right)\\ &=2^0P(Y\ge2^0)+\sum_{k=0}^\infty(2^{k+1}-2^k)P(Y\ge2^{k+1})\\ &=P(Y\ge1)+\sum_{k=0}^\infty2^kP(Y\ge2^{k+1}) \end{align} $$ Since the summation converges, $2^kP(Y\ge2^k)\to0$. Therefore, since $P(Y\ge x)$ is monotonic non-increasing, we get $$ \lim_{x\to\infty}x\,P(Y\ge x)=0 $$ Therefore, $$ \mathrm{E}(Y)=\int_0^\infty P(Y\ge x)\,\mathrm{d}x $$ For $\mathrm{E}(|X-a|)$, this becomes, $$ \begin{align} \mathrm{E}(|X-a|) &=\int_0^\infty P(|X-a|\ge x)\,\mathrm{d}x\\ &=\int_a^\infty P(X\ge x)\,\mathrm{d}x+\int_{-\infty}^a P(X\le x)\,\mathrm{d}x \end{align} $$

robjohn
  • 345,667
  • 1
    No need to assume the random variable is continuous. For nonnnegative $X$, set $I(x) = 1_{{X > x}|}$. Then $X = \int_0^\infty I(x) dx$. Take the expectation on both sides; Tonelli's theorem allows the interchange of integral and expectation. – Stephen Herschkorn Jul 20 '13 at 17:49
  • @StephenHerschkorn: Thanks. That is cleaner, but I didn't know how much background to assume. I presented what I thought was close to the level of the question, but I miss sometimes. – robjohn Jul 20 '13 at 18:06
  • Oho, do not really see throug this one. Why do I know that $P(Y>x)$ is differentiable? – Ferdinand Lampe Jul 21 '13 at 09:46
  • @FerdinandLampe In general it is not (differentiable). Which is why one should study and adopt the Tonelli approach to this specific question and to tons of similar ones, it being more powerful and more rigorous. – Did Jul 25 '13 at 12:48
  • @FerdinandLampe: Since $P(Y\ge x)$ is monotonic decreasing, it is differentiable almost everywhere. If it is not differentiable, one can use the Riemann-Stieltjes integral, as I have added above. – robjohn Jul 27 '13 at 03:55
  • @robjohn Why not use at the onset that E(Y) is the integral of P(Y>x), a formula you finally arrive at, whose (fully rigorous) proof is much simpler than what you explain (and does not require that Y is integrable). – Did Jul 30 '13 at 10:47
  • @Did: because I had thought that $\mathrm{E}(Y)=\int P(Y\ge x),\mathrm{d}x$ was part of the question. If that were a given, the answer would indeed be far simpler. – robjohn Jul 30 '13 at 16:06
  • OK. In that case you could show the "right" proof of this formula. – Did Jul 30 '13 at 19:12
  • @Did: I agree that the proof outlined by Stephen Herschkorn above is a cleaner proof. However, it requires certain prerequisites; e.g. familiarity with integration of functions whose values are a random variable, such as $\mathbf{1}_{{X\gt x}}$. Instead, I was paralleling the proof in analysis that $\int_X|f(x)|,\mathrm{d}x=\int_0^\infty \mu{x\in X:|f(x)|\gt\lambda},\mathrm{d}\lambda$, which is, in essence, the same. – robjohn Jul 30 '13 at 20:05
1

Note that the integrands are monotone. And therefore (improperly) Riemann integrable.

GEdgar
  • 111,679
  • Ok, more or less I got this one. But anyhow, I do not know how to continue (wether its now Riemann or not) with altering the equation.. I do not know how monotony of integrand implies Riemann integrable. I just know the thing on compact intervals and then Riemann=Lebesgue.. – Ferdinand Lampe Jul 20 '13 at 13:58
  • Well, the limit (as endpoints go to $\infty$) of the Lebesgue integrals is your answer (possibly $+\infty$) so that is also the (improper) Riemann integral. – GEdgar Jul 20 '13 at 14:14