This question has already answer in mathstackexchange.see here But I am approaching the problem in this way which is not present in mathstackexchange I think.
So Let $X$ be an RV such that $E|X| \lt \infty$. We have to Show that $E|X −c|$ is minimized if we choose $c=med(X)$. Now what I have tried this:
Let $m=med(x)$ and $c \geq m$ So I want to show $E|X-c|-E|X-m| \geq 0$
Now $|x-c|-|x-m|= \begin{cases} m-c & \text{ if $X \gt c$ } , \\ m-c+2(c-X) & \text{ if $m \leq X \leq c$}\\ c-m & \text{if $X \lt m$} \end{cases}$
Now if $X$ has a pdf $f$ then
$E|X-c|-E|X-m|= (m-c)P(X \gt c)+ (m-c) P(m \leq X \leq c) +2\int_{m}^{c} (c-X)f(x)dx+(c-m)P(X \lt m)$
After few steps we have
$E|X-c|-E|X-m|=-(c-m) +2(c-m)P(X \leq m)+ 2\int_{m}^{c} (c-X)f(x)dx$
Now the first two terms of rhs is greater than equal to 0 but how can I show $$2\int_{m}^{c} (c-X)f(x)dx \geq 0?$$
And similarly for $c \leq m$ we can show $E|X-c|-E|X-m| \geq 0$. So it is minimized at $c=med(X)$.
But in this way I think I never use any property of median. Is this correct way or am i missing something?
Any help is appreciated. Thanks