Does $P(X=a) = P(X=b) = \frac12$ maximize $\mathrm{Var}(X)$ over RVs a.s. taking values in $[a,b]$? I'm trying to maximize $\mathrm{Var}(X)$ over random variables a.s. taking values in $[a,b]$. In my original question I thought uniform was the best, but as was shown $P(X=a)=P(X=b) = \frac12$ gives $\mathrm{Var}(X) = \frac14(b-a)^2$ which is even greater than the variance for uniform.
I've tried showing this is the best and feel like I'm close, let $\mu=PX^{-1}$ :
$$
\mathrm{Var}(X) = \int_a^b(x-EX)^2d\mu =  \int_a^b(x-EX)^21_{X<EX}d\mu +  \int_a^b(x-EX)^21_{X>EX}d\mu
$$
$$
\leq (b-EX)^2P(X<EX) + (a-EX)^2P(X>EX).
$$
I don't see how to proceed after this. My intuition says that I should try to prove that a maximizer's distribution must be symmetric about $\frac{a+b}{2}$. This would show that a maximizer would have to have $P(X<EX) = P(X>EX)$ and that $EX = \frac{a+b}{2}$.
 A: Let $\mu=\mathbb{E}\left[ X \right]$. Then,
$$
\text{Var}(X) = \mathbb{E}\left[ (X - \mu)^{2}\right].
$$
Note that $\mu$ minimizes the function $f(z) = \mathbb{E}\left[ (X - z)^{2}\right]$. You can check that by taking the derivative of $f(z)$ w.r.t. $z$.
Hence, 
$$
\text{Var}(X)  \le f(z), \quad \forall z \in \mathbb{R}.
$$
and in turn, for $z = \frac{a+b}{2}$, we have
\begin{align}
\text{Var}(X)  
&\le \mathbb{E}\left[ \left(X - \frac{a+b}{2} \right)^{2}\right] \\
&= \frac{1}{4}\mathbb{E}\left[ \left(X - a + X - b \right)^{2}\right] \\
&\le \frac{1}{4}\mathbb{E}\left[ \bigl( (X - a) - (X-b) \bigr)^{2}\right]\\
&= \frac{1}{4}\mathbb{E}\left[ \bigl( b-a \bigr)^{2}\right].
\end{align}
The inequality follows from the fact that $X \le b$ and hence $X-b \le 0$.
We have shown that irrespectively of the distribution of $X$,
\begin{align}
\text{Var}(X)  
&\le  \frac{1}{4} \bigl( b-a \bigr)^{2}.
\end{align}
You have found a distribution that achieves this upper bound.
A: Alright I think I got it. We'll show that $\mu$ must be symmetric about $\frac{a+b}{2}$ by showing that if $\tilde X$ that has distribution $\frac{1}{2}(\mu + \nu)$, where $\nu$ is $\mu$ reflected about $\frac{a+b}{2}$, then $\mathrm{Var}(\tilde X) \geq \mathrm{Var}(X)$.
By construction $E\tilde X = \frac{a+b}{2}$ and 
$$\mathrm{Var}(\tilde X) = \int_a^b(x-(\frac{a+b}{2}))^2d(\frac{\mu + \nu}{2}) 
= \int_a^b(x-(\frac{a+b}{2}))^2d\mu 
$$
where here we use the symmetry of $\mu,\nu$ and note the fact that the integrand is invariant under reflection about $\frac{a+b}{2}$. Then this equals
$$
= EX^2 - (a+b)EX + (\frac{a+b}{2})^2
$$
which is bigger than $\mathrm{Var}(X) = EX^2 - (EX)^2$ iff
$$
(EX)^2-(a+b)EX + (\frac{a+b}{2})^2 \geq0
$$
but of course
$$
(EX)^2-(a+b)EX + (\frac{a+b}{2})^2 = (EX - \frac{a+b}{2})^2 \geq 0
$$
so indeed $\mathrm{Var}(\tilde X) \geq \mathrm{Var}(X)$.
Thus we can always increase the variance by symmetrizing. Concluding as in my question, for any $X$, we have
$$
\mathrm{Var}(X) \leq \mathrm{Var}(\tilde X) \leq (b- E\tilde X)^2 P(\tilde X< E\tilde X) + (a-E\tilde X)^2 P(\tilde X>E\tilde X)
$$
$$
\leq (b-\frac{a+b}{2})^2\frac12 + (\frac{a+b}{2}-a)^2\frac12 = \frac{(b-a)^2}{4} 
$$
where the $\leq$ in the previous line was not an equality because $\tilde X$ may have mass at $\frac{a+b}{2}$, so $P(\tilde X<E\tilde X) \leq \frac12$.
