Compute the sample variance?

A random sample of $n=484$ voters in a community produced $x=257$ voters in favor of candidate A. Compute the sample variance.

I have the solution but I don't follow some of the steps in it.

\begin{align} s^2&=\frac{1}{483} \cdot \sum_{i=1}^{484}(X_i-\bar X)^2\tag1\\ &=\frac{1}{483} \left[ 257\left(1-\frac{257}{484}\right)^2 + (484-257)\left(0-\frac{257}{484}\right)^2\right]\tag2\\ &=\frac{1}{483}\cdot48\cdot\frac{257}{484}\cdot\left(1-\frac{257}{484}\right)\tag3 \end{align}

I have no idea how to get from equation 1 to equation 2.

Going from equation 1 I get...

\begin{align} \frac{1}{483} \left(\sum_{i=1}^{484}X_i^2-484\left(\frac{257}{484}\right)^2\right)\tag4\\ \frac{1}{483} \left(\sum_{i=1}^{484}X_i^2-\frac{257^2}{484}\right)\tag5 \end{align}

I don't know what to do with $\sum_{i=1}^{484}X_i^2$

I had an idea that the problem should use the Binomial variance $np(1-p)$ but nothing in equation 2 looks like that to me so I'm just entirely lost.

Edit: I noticed that I erroneously excluded parenthesis around the factor in my eq 4 and 5 which I've since added in which, of course, made all the difference.

2 Answers

Here, you can view the samples as a string of ones and zeros (where one means they voted for candidate $A$), and the sample variance is the variance of that. Everything you have done seems to have been consistent with that. But now it should be clear that $X_i^2 = X_i,$ so you can interpret $$\sum_{i=1}^{484} X_i^2 = 257.$$ You will see that the answer is somewhat reminiscent of the binomial variance, like you expected.

For your attempt remember $$(X_i - \bar{X})^2 \ne X_i^2 - \bar{X} ^2$$

We go from equation 1 to equation 2 by noting there are $257$ such $X_i$ that equal 1 and $484-257$ such $X_i$ that equal 0.