Variational problem concerning variances Let $\phi$ be the family consisting of all random variables $X$ such that $P(X\in [0,1])=1$, $EX=\frac{1}{3}$, $P(X<\frac{1}{4})<\frac{1}{2}$, $P(X>\frac{1}{4})\geq\frac{1}{2}$. Calculate $\sup \{Var(X):X \in \phi\} - \inf \{Var(X):X \in \phi\} .
$

Let us put $I=\inf({\sf Var}(X)|X\in\phi)$ and $S=\sup({\sf Var}(X)|X\in\phi)$. We will 
compute $I$ and $S$. 
Trivially $I=0$ (take $X$ constant equal to $\frac{1}{3}$).
Let us now compute $S$. To ease notation, we introduce the
characteristic functions $\alpha=1_{X\in[0,\frac{1}{4})}$ and $\beta=1_{X\in[\frac{1}{4},1]}$,
so that $\alpha+\beta=1$, and we shall abuse notation slightly by putting 
$E_{\alpha}(\ldots)$ (or $E_{\beta}(\ldots))$ instead of $E(\alpha\ldots)$ 
( or $E(\beta\ldots))$. We then have a formal identity 
$E=E_{\alpha}+E_{\beta}$. For $X\in\phi$, one has
$$
\begin{array}{lcl}
E(X^2) &= & E_{\alpha}(X^2)+E_{\beta}(X^2) \\
  &\leq & E_{\alpha}\bigg(\frac{1}{4}X \bigg) +E_{\beta}\bigg(X^2+(1-X)(X-\frac{1}{4}) \bigg) \\
  &= & \frac{1}{4}E_{\alpha}\bigg(X \bigg) +E_{\beta}\bigg(\frac{5}{4}X-\frac{1}{4} \bigg) \\
  &= & \frac{1}{4}E_{\alpha}\bigg(X \bigg) +E\bigg(\frac{5}{4}X-\frac{1}{4} \bigg)-
  E_{\alpha}\bigg(\frac{5}{4}X-\frac{1}{4} \bigg) \\
  &= & \frac{1}{4}E_{\alpha}\bigg(X \bigg) +\frac{5}{4}\times\frac{1}{3}-\frac{1}{4} -
  \frac{5}{4}E_{\alpha}\bigg(X\bigg)+\frac{1}{4}P(X<\frac{1}{4})  \\
  &= & \frac{1}{6}-E_{\alpha}\bigg(X \bigg)+\frac{1}{4}P(X<\frac{1}{4})  \\
  & \leq & \frac{1}{6}+\frac{1}{4}P(X<\frac{1}{4}) \leq \frac{1}{6}+\frac{1}{4}\times
  \frac{1}{2} =\frac{7}{24}  \\
\end{array}
$$
The inequality $E(X^2) \leq \frac{7}{24}$ cannot become an inequality, because
it would entail $P(X<\frac{1}{4})=\frac{1}{2}$ contradicting $X\in\phi$. The bound
$\frac{7}{24}$ is best possible, however. Indeed, for $n\geq 10$ consider $f_n:[0,1]\to {\mathbb R}^{+}$ defined
by
$$
f_n(x)=\left\lbrace\begin{array}{lcl}
2n-\frac{1}{4}+\frac{1}{8(n-1)}, & \text{if} & x\in[0,\frac{1}{4n}] \\
\frac{1}{8(n-1)}, & \text{if} & x\in[\frac{1}{4}-\frac{1}{4n},\frac{1}{4}] \\
\frac{8n}{27}+\frac{5}{27}+\frac{31}{216(n-1)}, & \text{if} & x\in[\frac{1}{4},\frac{1}{4}+\frac{3}{4n}] \\
\frac{10n}{27}-\frac{11}{108}-\frac{31}{216(n-1)}, & \text{if} & x\in[1-\frac{3}{4n},1] \\
0, & \text{otherwise} &
\end{array}\right.
$$
and let $X_n$ have density $f_n$. Then $E(X_n)=\frac{1}{3},P(X_n<\frac{1}{4})=\frac{1}{2}-\frac{1}{16n}$
so $X_n\in\phi$, and $E(X_n^2)=\frac{7}{24}-\frac{45n^2 - 17n - 2}{192n^3}$. So $\frac{7}{24}$ is best possible,
and hence $S=\frac{7}{24}-\bigg(\frac{1}{3}\bigg)^2=\frac{13}{72}$. 
In the end, $S-I=\frac{13}{72}$.
