Variance of a sum of correlated random variables. The final line of the work is right but it does not make sense to me

[Problem.] Suppose that $X_1,\ldots, X_{100}$ are random variables with $\operatorname E X_i=100$ and $\operatorname E X_i^2=10100.$ If $$\operatorname{Cov}(X_i,X_j)=-1\ \ \text{for i\ne j,}$$
what is $\operatorname{Var}S,$ where $S= \sum_{i=1}^{100} X_i$?

[Solution.] To solve for $\operatorname{Var}S$ it makes sense to me to solve for $\operatorname{Var}X_i$ first. Thus, $$\operatorname{Var}X_i= 10100-10000=10100-(100^2)=100.$$ Now to solve for $\operatorname{Var}S,$ $$\operatorname{Var}S=100\operatorname{Var}X_i- \binom{100} 2 \cdot 2.$$

Question: I understand why $100\operatorname{Var}X_i$ is necessary but where did $\binom{100}2 \cdot 2$ come from?

• Everything makes sense now besides {n+1 \choose 2k} s.t.n+1=100 and k=1 – Jordan Greenhut Jan 9 '18 at 1:31

$\newcommand{\v}{\operatorname{var}} \newcommand{\c}{\operatorname{cov}}$ \begin{align} \v \sum_{i=1}^{100} X_i & = \left( \sum_{i=1}^{100} \v(X_i) \right) + \sum_{i=1}^{100} \sum_{(\,j\,:\, j\,\ne\,i\,)} \c(X_i,X_j) \\[10pt] & = \left( \sum_{i=1}^{100} 100 \right) + \sum_{i=1}^{100} \sum_{(\,j\,:\, j\,\ne\,i\,)} (-1) \\[12pt] & = \Big( 100\times\text{number of terms} \Big) + \Big( (-1)\times\text{number of terms} \Big) \\[12pt] & = (100\times100) + ((-1) \times(100\times 99)). \end{align} The reason this is $100\times99,$ i.e. the reason that that is how many terms there are, is that for every value of $i$ there are $99$ possible values of $j.$ Or for every value of $j$ there are $99$ possible values of $i.$
One can also say the number of unordered pairs is $\dbinom{100}2,$ but for each of those there are two ordered pairs, so it's $\dbinom{100}2\times 2,$ which is the same as $100\times99.$