# Variance

## In words...

The variance of a random variable ...

The variance of bounded random variables can be bounded.

## In maths...

The variance of a random variable $X$ of mean $\E X$ is defined as $$Var(X) = \E \left[ (X - \E X)^2 \right] .$$

### Properties of the variance

The variance can be also be computed as \begin{align} Var(X) &= \E\left[ X^2 + (\E X)^2 - 2X\E X \right] = \E\left[ X^2\right] + (\E X)^2 - 2 (\E X)^2 \\ &= \E\left[ X^2\right] - (\E X)^2 \end{align}

The variance is invariant to translations: $$\forall x\in \R, \quad Var(X-x) = Var(X) .$$

Using the linearity of the expectation, we have \begin{align} Var(X-x) &= \E\left[ \left(X-x -\E(X-x) \right)^2 \right] \\ &= \E\left[ \left(X-x -\E X + x \right)^2 \right] \\ &= \E\left[ \left(X -\E X \right)^2 \right] \\ &= Var(X) \end{align}

### Variance of a bounded random variable

If the random variable $X$ is bounded, i.e., it takes values in $[a,b]$ with finite $a$ and $b$, then $$Var(X) \leq \frac{(b-a)^2}{4} .$$

Consider the function $f(t) = \E (X - t)^2 = \E X^2 -2t\E X + t^2$. We have the derivative $$\frac{df}{dt} = 2t -2\E X ,$$ which is zero at $t=\E X$. Since, in addition, the second derivative $d^2 f / dt^2 = 2$ is positive, the function attains its minimum at $t=\E X$ for which it equals the variance $Var(X) = \E(X -\E X)^2$. Thus, $$\forall t\in \R, \quad Var(X) \leq f(t)$$ and in particular, \begin{align} Var(X) &\leq f\left(\frac{b-a}{2} \right) = \E \left(X - \frac{b-a}{2}\right)^2 \end{align} Let define the random variable $Z=\left(X - \frac{b-a}{2}\right)^2$. Given that $X\in[a,b]$, we have $Z \leq \frac{(b-a)^2}{4}$ and thus $\E Z \leq \frac{(b-a)^2}{4}$, which yields the desired result.