# How to prove a random variable taking values in $[0,1]$ range has variance no larger than $\frac{1}{4}$?

How can I prove that a random variable taking values in $[0,1]$ has variance no larger than $\frac{1}{4}$? If it matters, discrete and continuous proofs are both welcome.

-

Let $X$ a random variable with $0\leq X\leq 1$. We have $$\operatorname{Var}(X)=E[X^2]-E[X]^2\le E[X]-E[X]^2=E[X](1-E[X]).$$ Now, we note that for $0\leq t\leq 1$, we have $$t(1-t)=-(t^2-t)=-\left(\left(t-\frac 12\right)^2-\frac 14\right)=\frac 14-\left(t-\frac 12\right)^2\leq \frac 14,$$ with equality if $t=\frac 12$.
With a Bernoulli law ($P(X=1)=1/2$ and $P(X=0)=1/2$) you get an equality.
Why is $E[X^2] \leq E[X]$? (does that always apply or is it only in the range 0 to 1?) Oh I see, its because $0 \leq X \leq 1$. –  Pinocchio Jan 12 '14 at 8:25
We have indeed have $X^2\leqslant X$ because $0\leqslant X\leqslant 1$. –  Davide Giraudo Jan 12 '14 at 10:01
Simple calculus shows that the mean $\mu_X$ is the constant with smallest mean squared distance from $X$. Combined with the condition $0 \leq X\leq 1$, this gives $$\mbox{Var}(X)=\mathbb{E}[(X-\mu_X)^2]\leq \mathbb{E}\left[\left(X-{1\over 2}\right)^2\right]\leq {1\over 4}.$$