Maximum of the Variance Function for Given Set of Bounded Numbers

Solution 1:

Since $x_i \leq c$, $\displaystyle \sum_i x_i^2 = \sum_i x_i\cdot x_i \leq \sum_i c\cdot x_i = cn\bar{x}.$ Note also that $0 \leq \bar{x} \leq c$. Then, $$ \begin{align*} n\cdot \text{var}(\mathbf{x}) &= \sum_i (x_i - \bar{x})^2= \sum_i x_i^2 - 2x_i\bar{x} + \bar{x}^2\\ &= \sum_i x_i^2 - 2\bar{x}\sum_i x_i + n\bar{x}^2= \sum_i x_i^2 - n\bar{x}^2\\ &\leq cn\bar{x} - n\bar{x}^2 = n\bar{x}(c-\bar{x}) \end{align*} $$ and thus $$\text{var}(\mathbf{x}) \leq \bar{x}(c-\bar{x}) \leq \frac{c^2}{4}.$$

Added note: (second edit)
The result $\text{var}(X) \leq \frac{c^2}{4}$ also applies to random variables taking on values in $[0,c]$, and, as my first comment on the question says, putting half the mass at $0$ and the other half at $c$ gives the maximal variance of $c^2/4$. For the vector $\mathbf x$, if $n$ is even, the maximal variance $c^2/4$ occurs when $n/2$ of the $x_i$ have value $0$ and the rest have value $c$. Someone else posted an answer -- it has since been deleted -- which said the same thing and added that if $n$ is odd, the variance is maximized when $(n+1)/2$ of the $x_i$ have value $0$ and $(n-1)/2$ have value $c$, or vice versa. This gives a variance of $(c^2/4)\cdot(n^2-1)/n^2$ which is slightly smaller than $c^2/4$. Putting the "extra" point at $c/2$ instead of at an endpoint gives a slightly smaller variance of $(c^2/4)\cdot(n-1)/n$, but both choices have variance approaching $c^2/4$ asymptotically as $n \to \infty$.

Solution 2:

An easier derivation can be done as follows (From [1]):

For any constant $c$, we have, \begin{equation} E[(X-c)^2] = E[X^2] - 2E[X]c + c^2 \end{equation} The above quadratic is minimized when $c=E[X]$. It follows that, \begin{equation} \sigma^2 = E[(X-E[X])^2] \leq E[(X-c)^2], \text{for all } c \end{equation} By letting $c = (a+b)/2$, we obtain, \begin{equation} \sigma^2 \leq E\left[\left(X-\frac{a+b}{2}\right)^2\right] = E[(X-a)(X-b)] + \frac{(b-a)^2}{4} \leq \frac{(b-a)^2}{4} \end{equation}

since for $x$ in $[a,b]$, $(x-a)(x-b)<0$

Further, the bound could be very conservative. However, in the absence of any other information about $X$, it can not be improved.

[1] D. P. Bertsekas and J. N. Tsitsiklis, Introduction to Probability. Athena Scientific, 2002.