Characterise the minimizer of a function that includes the expectation

Let $X \in L^1.$ I need to characterize the minimizer of the function: $$ d(x) = \mathbb{E} [|X-x|], \,\, x\in \mathbb{R}.$$ Let m be the minimizer we are looking for. Then for $x\leq m$ (and eventually for $x \geq m$) , I want to show the following,$\,\,d(m) -d(x)\leq (m-x) (\mathbb{P} (X< m) -\mathbb{P} (X \geq m)) $ : $$d(m) -d(x) = \mathbb{E} [|X-m|] - \mathbb{E} [|X-x|] \leq \int_{\mathbb{R}} X^{+} + X^{-} + |m|\,\,\, d \mathbb{P} \,\,- \int_{\mathbb{R}} X^{+} + X^{-} + |x|\,\,\, d \mathbb{P} = (|m|-|x|) \int_{\mathbb{R}} \,\,\, d \mathbb{P}.$$

Since $m$ is a minimizer, $d(m)-d(x)\leq 0.\,\,$ I am not sure how I can go from here.

Can somebody provide some support or a solution proposal ? Thanks.


Let $\phi(x) = \int |x-X| dP = \int g_X(x) dP$. Note that $\phi$ is defined everywhere, convex and $\phi(x) \to \infty$ as $|x| \to \infty$. In particular, $\phi$ has a minimiser.

Write $[X \le x]$ for $\{ \omega | X(\omega) \le x \}$, etc. For a function $\phi$ denote the one sided directional derivative at $x$ in the direction $h$ as $d \phi(x;h)$.

Fix some $\alpha$ and let $g_\alpha(x) = |x-\alpha|$. Note that $d g_\alpha (x;+1) = \begin{cases} +1, & x \ge \alpha\\ -1, & \text{otherwise} \end{cases}$, and $d g_\alpha (x;-1) = \begin{cases} +1, & x \le \alpha\\ -1, & \text{otherwise} \end{cases}$.

Note that the directional derivative of $g_\alpha$ is defined everywhere.

Let $l=P[X<x], e=P[X=x], g=P[X>x]$.

An application of the dominated convergence theorem shows that with $h =\pm 1$ we have $d \phi(x; h) = \int dg_X(x;h) dP$ from which we get $d \phi(x; +1) = l+e-g$, $d \phi(x; -1) = g+e-l$.

Since $\phi$ is convex, we have $x^*$ is a minimiser iff $d \phi(x^*,+1) \ge 0$ and $d \phi(x^*,-1) \ge 0$.

Hence $x$ is a minimiser of $\phi$ iff $l+e \ge g$ and $g+e \ge l$. Combining with $l+e+g = 1$ this gives $l+e \ge {1 \over 2}$, $g+e \ge {1 \over 2}$.

Now suppose $l+e \ge {1 \over 2}$, $g+e \ge {1 \over 2}$, then from $l+e+g = 1$ we get ${1 \over 2} \ge g$ and ${1 \over 2} \ge l$ and so $l+e \ge g$ and $g+e \ge l$.

In particular, we see that $x$ is a minimiser iff $P[X \le x] \ge {1 \over 2}$ and $P[X \ge x] \ge {1 \over 2}$.

This is the definition of the median (see https://en.wikipedia.org/wiki/Median#Probability_distributions).