# Maximum of Variance

Suppose that a vector $x \in \mathbb{R}^n$ consists of the elements which are in $[0, c]$ for a positive real number $c$. Then \begin{aligned} \sum_{i=1}^n x_i^2 \le \sum_{i=1}^n c x_i = c \sum_{i=1}^n x_i = cn\overline{x} \end{aligned}

where $\overline{x}$ is the mean of $x$ elements. Let $Var(x)$ be the variance of $x$ elements, then \begin{aligned} Var(x) &= \frac{1}{n} \sum_{i=1}^n (x_i - \overline{x})^2 = \frac{1}{n} \sum_{i=1}^n (x_i^2 - 2\overline{x}x_i + \overline{x}^2) \\ &= \frac{1}{n} \left\{ \sum_{i=1}^n x_i^2 - 2\overline{x} \sum_{i=1}^n x_i + n \overline{x}^2 \right\} \\ &= \frac{1}{n} \left\{ \sum_{i=1}^n x_i^2 - 2n\overline{x}^2 + n \overline{x}^2 \right\} \\ &= \frac{1}{n} \left\{ \sum_{i=1}^n x_i^2 - n\overline{x}^2 \right\} \\ &\le \frac{1}{n} (cn\overline{x} - n\overline{x}^2) = c\overline{x} - \overline{x}^2 \end{aligned}

If we define $f(\overline{x}) = c\overline{x} - \overline{x}^2$, then its extreme value is as follows: $\begin{gather} f(\overline{x}) = c\overline{x} - \overline{x}^2 \\ f'(\overline{x}) = c - 2\overline{x} = 0 \implies \overline{x} = \frac{c}{2} \\ f\left( \frac{c}{2} \right) = \frac{c^2}{2} - \frac{c^2}{4} = \frac{c^2}{4} \end{gather}$

It yields the following boundary. \begin{aligned} Var(x) \le c\overline{x} - \overline{x}^2 \le \frac{c^2}{4} \end{aligned}