8 added 2 characters in body

Lemma 1. If $f$ is not convex, then we can find a random variable $X$ such that $\mu (f(X)) - f(\mu (X)) < m(f(X)) - f(m(X))$.

Proof. If $f$ is not convex, then, by definition, there exist two points $a \neq b$ and a $p \in (0,1)$ such that $f(pa + (1-p)b) > pf(a) + (1-p)f(b)$. If this inequality holds for $p = 1/2$ but not for $p = 3/4$, then it also holds with $p = 2/3$ and $a$ replaced by $3a/4 + b/4$. Thus, WLOG we can assume that $f(pa + (1-p)b) > pf(a) + (1-p)f(b)$ for some $a \neq b$ and $p > 1/2$. Define random variable $X$ as follows: ${\rm P}(X = a) = p$, ${\rm P}(X = b) = 1-p$. Then, $m(X) = a$ and $m(f(X)) = f(a)$, so $m(f(X)) - f(m(X)) = 0$. The lemma now follows from $\mu (f(X)) - f(\mu (X)) = pf(a) + (1-p)f(b) - f(pa + (1-p)b) < 0$.

Lemma 2. If for some $a < b < c$, $f(a) = f(c) > f(b)$, then we can find a random variable $X$ such that $\mu (f(X)) - f(\mu (X)) < m(f(X)) - f(m(X))$.

Proof. Fix $\varepsilon > 0$ sufficiently small. Define random variable $X$ as follows: ${\rm P}(X=b) = 1/2 - \varepsilon$, ${\rm P}(X=a) = (1/2 + \varepsilon)(c - b)/(c - a)$, ${\rm P}(X=c) = (1/2 + \varepsilon)(b - a)/(c - a)$. Then, $\mu(X)=m(X)=b$, and ${\rm P}[f(X) = f(b)] = 1/2 - \varepsilon$, ${\rm P}[f(X) = f(a)]= 1/2 + \varepsilon$. The lemma now follows from $\mu(f(X)) = (1/2 - \varepsilon)f(b) + (1/2 + \varepsilon)f(a) < f(a) = m(f(X))$.

From Lemmas 1 and 2, we conclude:

Corollary. The inequality $\mu (f(X)) - f(\mu (X)) \geq m(f(X)) - f(m(X))$ holds for any (integrable) random variable $X$ only if $f$ is convex and monotone.

EDIT: A somewhat trivial extension of this corollary ("if part").

Suppose that $f$ is a strictly monotone convex function, defined on an interval $I$ containing the range of an integrable rv $X$. If $m(X)$ is unique, then so is $m(f(X))$, and it holds $\mu (f(X)) - f(\mu (X)) \geq m(f(X)) - f(m(X)) = 0$.

Proof. By Jensen's inequality, $\mu (f(X)) - f(\mu (X)) \geq 0$. So, it remains to show that $m(f(X)) = f(m(X))$. Suppose that $\tilde m \in f(I)$ is a median of $f(X)$. Then, by definition, ${\rm P}(f(X) \leq \tilde m) \geq 1/2$ and ${\rm P}(f(X) \geq \tilde m) \geq 1/2$. Taking inverses shows that $f^{-1}(\tilde m)$ is a median of $X$. Thus, $f^{-1}(\tilde m) = m(X)$, and the assertion follows.

7 added 764 characters in body

Corollary. The inequality $\mu (f(X)) - f(\mu (X)) \geq m(f(X)) - f(m(X))$ holds for any (integrable) random variable $X$ only if $f$ is convex and monotone.

EDIT: A somewhat trivial extension of this corollary ("if part").

Suppose that $f$ is a strictly monotone convex function, defined on an interval $I$ containing the range of an integrable rv $X$. If $m(X)$ is unique, then so is $m(f(X))$, and it holds $\mu (f(X)) - f(\mu (X)) \geq m(f(X)) - f(m(X)) = 0$.

Proof. By Jensen's inequality, $\mu (f(X)) - f(\mu (X)) \geq 0$. So, it remains to show that $m(f(X)) = f(m(X))$. Suppose that $\tilde m \in f(I)$ is median of $f(X)$. Then, by definition, ${\rm P}(f(X) \leq \tilde m) \geq 1/2$ and ${\rm P}(f(X) \geq \tilde m) \geq 1/2$. Taking inverses shows that $f^{-1}(\tilde m)$ is a median of $X$. Thus, $f^{-1}(\tilde m) = m(X)$, and the assertion follows.

6 added 235 characters in body; deleted 86 characters in body

The following example rules out

Lemma 1. If $f$ is not convex, then we can find a substantial class of functions random variable $X$ such that $\mu (f(X)) - f(\mu (X)) < m(f(X)) - f(m(X))$.

Proof. If $f$ is not convex, then, by definition, there exist two points $a \neq b$ and a $p \in (0,1)$ such that $f(pa + (1-p)b) > pf(a) + (1-p)f(b)$. Suppose If this inequality holds for $f(a) p = f(-a) 1/2$ but not for $p = 3/4$, then it also holds with $p = 2/3$ and $a$ replaced by $3a/4 + b/4$. Thus, WLOG we can assume that $f(pa + (1-p)b) > f(0)$pf(a) + (1-p)f(b)$ for some $a \neq 0$b$ and $p > 1/2$. Define random variable $X$ as follows: ${\rm P}(X=0) P}(X = {\rm P}(X=aa) = {\rm P}(X=-ap$, ${\rm P}(X = b) = 1/3$1-p$. Then, $\mu(X)=m(X)=0$, m(X) = a$ and ${\rm P}[f(X) = f(0)] m(f(X)) = 1/3$f(a)$, so ${\rm P}[f(Xm(f(X)) - f(m(X)) = f(a)]=2/3$0$. However,The lemma now follows from $\mu(f(X)) \mu (f(X)) - f(\mu (X)) = pf(a) + (1/3)f(0) 1-p)f(b) - f(pa + (2/3)f(a) 1-p)b) < f(a) = m(f(X))$0$. EDIT: Substantial generalization Lemma 2. Suppose that If for some $a < b <c$< c$, $f(a) = f(c) > f(b)$, then we can find a random variable $X$ such that $\mu (f(X)) - f(\mu (X)) < m(f(X)) - f(m(X))$.

Proof. Fix $\varepsilon > 0$ sufficiently small. Define random variable $X$ as follows: ${\rm P}(X=b) = 1/2 - \varepsilon$, ${\rm P}(X=a) = (1/2 + \varepsilon)(c - b)/(c - a)$, ${\rm P}(X=c) = (1/2 + \varepsilon)(b - a)/(c - a)$. Then, $\mu(X)=m(X)=b$, and ${\rm P}[f(X) = f(b)] = 1/2 - \varepsilon$, ${\rm P}[f(X) = f(a)]= 1/2 + \varepsilon$. However, The lemma now follows from $\mu(f(X)) = (1/2 - \varepsilon)f(b) + (1/2 + \varepsilon)f(a) < f(a) = m(f(X))$.

EDIT:

Similarly to above

From Lemmas 1 and 2, we can also rule out the class of functions $f$ such that for some $a < b < c$, $f(a) = f(c) < f(b)$. Fix any $\varepsilon \in (0,1/2)$. Define random variable $X$ as followsconclude:${\rm P}(X=b) = 1/2 + \varepsilon$,

Corollary. The inequality ${\rm P}(X=a) = \mu (1/2 - \varepsilon)(c - b)/(c f(X)) - a)$, ${\rm P}(X=c) = f(\mu (1/2 - \varepsilon)(b - a)/(c - a)$. Then, $\mu(X)=m(X)=b$, and ${\rm P}[f(X) = f(b)] = 1/2 + X)) \varepsilon$, ${\rm P}[f(Xgeq m(f(X)) = f(a)]= 1/2 - \varepsilon$. However, f(m(X))$holds for any random variable $\mu(f(X)) = (1/2 + \varepsilon)f(b) + (1/2 - \varepsilon)f(a) < f(b) = m(f(X))$X$ only if $f$ is convex and monotone.

5 added 583 characters in body
4 added 40 characters in body
3 added 529 characters in body
2 deleted 19 characters in body
1