The definition of median, $m$, for a continuous random variable $X$ is $$P(X\leq m)=P(X\geq m)=\int_{-\infty}^m f(x)\text{d}x=\int_{m}^{\infty}f(x)\text{d}x=\frac{1}{2}$$

where $f(x)$ is the pdf of $X$.

Now the problem goes as follows:

Show that if $X$ is a continuous random variable, then $$min_{a} (E|X-a|)=E|X-m|$$

The work I have done for this problem:


Have that $$E|X-a|=\int_{\mathbb{R}} |x-a|f(x)\text{d}x=\int_{a}^{\infty}(x-a)f(x)\text{d}x-\int_{-\infty}^a (x-a)f(x)\text{d}x$$ Differentiation with respect to $x$ gives us $$\frac{d}{dx}E|X-a|=\int_{a}^{\infty} f(x)\text{d}x-\int_{-\infty}^a f(x)\text{d}x$$ Setting this equal to 0, we find that $$\int_{a}^{\infty} f(x)\text{d}x= \int_{-\infty}^a f(x)\text{d}x$$ We know that $$\int_{\mathbb{R}}f(x)\text{d}x=1$$ $$\implies \int_{a}^{\infty} f(x)\text{d}x= \int_{-\infty}^a f(x)\text{d}x=\frac{1}{2}$$ Hence, $a$ must be our median, by definition.

What I am confused on is showing the minimal property. I looked up what I could, and it appears that using the second derivative to show that we produce a positive value for f(a) present us with minimality, but I don't really understand why. Potentially a very naïve question, but why does f(a)>0 for second-derivative have significance? Is it because of the absolute-value property on $X-a$?

  • $\begingroup$ self-study flag missing? $\endgroup$
    – Xi'an
    Commented Feb 10, 2015 at 7:18
  • $\begingroup$ The derivative is not quite right: its sign is in error. Based on that, you should conclude that the median maximizes $E|X-a|$. $\endgroup$
    – whuber
    Commented Feb 10, 2015 at 15:58
  • 1
    $\begingroup$ The variable of interest is $a.$ So the derivative should be taken with respect to $a.$ $\endgroup$
    – soakley
    Commented Feb 10, 2015 at 18:48

1 Answer 1


Based on your work, $$ I(a) = \frac{d}{da} E|X-a| = \int_a^{\infty} f(x) ~ dx - \int_{-\infty}^a f(x) ~ dx $$ If $a=m$, then $I(m) = 0$.

Think of $I(a)$ geometrically. You have a probability mass functions $f(x)$. Geometrically $I(a)$ is the area of the right-half of the curve minus the left-half of the curve at the point $a$. Therefore, if $I(m) = 0$ and $a>m$ then, as you are weighing the curve now more to the left, $I(a) < 0$. By a similar argument, $I(a) > 0$ if $a<m$.

Ignore the second-derivative test. Use the first-derivative instead here. As $I(a) = 0$ at $a=m$, $I > 0$ for $a>m$, and $I<0$ for $a<m$, it follows that at $a=m$ we have a minimum point.

  • $\begingroup$ Once I get more reputation, I shall give you an upvote. Thank you very much, my friend. This was incredibly helpful :D $\endgroup$ Commented Feb 10, 2015 at 6:46
  • 1
    $\begingroup$ Your argument would be correct if you used the correct derivative. With your expression for $I(a)$, it approaches $-1$ as $a\to\infty$ and $1$ as $a\to -\infty$, proving that $m$ is a maximum of $I$, not a minimum. $\endgroup$
    – whuber
    Commented Feb 10, 2015 at 16:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.