# How to prove the largest gap between mean and median

I am interested in an upper bound on the largest possible gap between the mean and median of a probability distribution on [0,1]. I am only interested in continuous density functions. My conjecture is that the upper bound is 0.5 but I can’t see how to prove it. Any help much appreciated.

If $$X$$ has a finite second moment, then one can prove that $$|\text{Median}(X) - \mathbb{E}(X)| \leq \sqrt{\operatorname{Var}(X)}.$$ Then, you can also prove that if $$X$$ is bounded in $$[0,c]$$ then $$\operatorname{Var}(X) \leq \frac{c}{4}.$$ In your case $$c=1$$ so that $$\operatorname{Var}(X) \leq1/4.$$ Combining these results, $$|\text{Median}(X) - \mathbb{E}(X)| \leq \sqrt{1/4} = 0.5.$$

• Can you say something about how to prove the first inequality?
– Simd
May 20, 2023 at 8:03
• Take a look at this question. May 20, 2023 at 8:27

This replaces a since-deleted incorrect answer of mine.

Let $$F$$ be the distribution function of a random variable $$X$$ taking values in $$[0,1]$$, let its median be $$m$$ and its mean be $$\mu$$. We have $$F(m)=1/2$$ and (by integration by parts) $$\mu=\int_0^1(1-F(x))\,dx$$.

For given value of $$m$$, what $$F$$ maximizes $$\mu$$? Clearly $$1-F(x)\le1$$ on $$[0,m)$$ and $$1-F(x)\le 1/2$$ on $$[m,1]$$, so $$\mu\le m + (1-m)/2 = (1+m)/2$$.

And for given $$m$$, what $$F$$ minimizes $$\mu$$? Clearly $$1-F(x)\ge 1/2$$ on $$[0,m)$$ and $$1-F(x)\ge1$$ on $$[m,1]$$, so $$\mu\ge m/2$$.

Summarizing, $$-\frac{m}2\le \mu-m\le \frac{ 1-m}2.$$

Since $$m\in[0,1]$$ this delivers the sought-after bound $$|\mu-m|\le 1/2$$. The values $$\mu-m=\pm1/2$$ cannot be attained by distributions with continuous density functions, but all in-between values can