Variance of Discrete Uniform Distribution

Theorem

Let $X$ be a discrete random variable with the discrete uniform distribution with parameter $p$.

Then the variance of $X$ is given by:

$\operatorname{var} \left({X}\right) = \dfrac {n^2 - 1} {12}$

Proof

From the definition of Variance as Expectation of Square minus Square of Expectation:

$\operatorname{var} \left({X}\right) = E \left({X^2}\right) - \left({E \left({X}\right)}\right)^2$
$\displaystyle E \left({X^2}\right) = \sum_{x \mathop \in \Omega_X} x^2 \Pr \left({X = x}\right)$

So:

 $\displaystyle E \left({X^2}\right)$ $=$ $\displaystyle \sum_{k \mathop = 1}^n k^2 \left({\frac 1 n}\right)$ $\quad$ Definition of Discrete Uniform Distribution $\quad$ $\displaystyle$ $=$ $\displaystyle \frac 1 n \sum_{k \mathop = 1}^n k^2$ $\quad$ $\quad$ $\displaystyle$ $=$ $\displaystyle \frac 1 n \frac {n \left({n + 1}\right) \left({2 n + 1}\right)} 6$ $\quad$ Sum of Sequence of Squares $\quad$ $\displaystyle$ $=$ $\displaystyle \frac{\left({n + 1}\right) \left({2 n + 1}\right)} 6$ $\quad$ $\quad$

Then:

 $\displaystyle \operatorname{var} \left({X}\right)$ $=$ $\displaystyle E \left({X^2}\right) - \left({E \left({X}\right)}\right)^2$ $\quad$ $\quad$ $\displaystyle$ $=$ $\displaystyle \frac {\left({n + 1}\right) \left({2 n + 1}\right)} 6 - \frac {\left({n + 1}\right)^2} 4$ $\quad$ Expectation of Discrete Uniform Distribution: $E \left({X}\right) = \dfrac {n + 1} 2$ $\quad$ $\displaystyle$ $=$ $\displaystyle \frac {2 \left({2 n^2 + 3 n + 1}\right) - 3 \left({n^2 + 2 n + 1}\right)} {12}$ $\quad$ $\quad$ $\displaystyle$ $=$ $\displaystyle \frac {n^2 - 1} {12}$ $\quad$ $\quad$

$\blacksquare$