Exercise 3.3.b in Grimmett & Stirzaker's 'Probability and Random Processes Here the question is:
Each member of a group on $n$ players rolls a die:
Find the mean and variance of the total score ($S_n$) if any players who threw the same number scores that number.
The solution is as follows:
Let $X_{ij}$ be the common score of players $i$ and $j,$ so that $X_{ij}=0$ if there scores are different. The first part I follow, the expected total score is:
$$E[S_n] =\binom{n}{2}E(X_{12})=\binom{n}{2}\frac{1}{6}\frac{7}{2}$$
I don't see how they get the expression for the variance:
\begin{align} \operatorname{var}(S) &= E \left \{\left(\sum_{i<j}X_{ij}\right)^2 \right \}-E(S)^2  \\  
& = \binom{n}{2}E(X_{12}^2) + \binom{n}{3}E(X_{12}X_{23})+\left\{ \binom{n}{2}^2-\binom{n}{2} - \binom{n}{3}\right \}E(X_{12})^2-(\frac{7}{12})^2 (\binom{n}{2})^2 \end{align}
I would only expect to see the first and last terms in the last line, where do there other terms come from? 
 A: When you expand out $(\sum_{i<j} X_{i,j})^2=(X_{12}+X_{13}+X_{23}+X_{14}+\dots)^2$, there are three types of terms which appear:


*

*$X_{ij}X_{ij}$; There are $\binom{n}2$ of these, and their expectation is the same as $E[X_{12}^2]$

*$X_{ij}X_{jk}$, where $j\neq k$: There are $\color{red}{\binom{n}{3}}$ of these, since there are three ways to choose the values of $i,j,k$. Each choice the same expectation as $X_{12}X_{23}$.

*$X_{ij}X_{k\ell}$, where $i,j,k,\ell$ are pairwise distinct. This accounts for every other choice; since there are $\binom{n}2^2$ products total, the number is found by subtracting the counts in the previous two bullets from $\binom{n}2^2$. Note, by independence and symmetry, $$E[X_{ij}X_{k\ell}]=E[X_{ij}]E[X_{k\ell}]=E[X_{12}]E[X_{12}]=E[X_{12}]^2.$$ 


However, I think the solution has a mistake in the second bullet. The three numbers $i,j,k$ are not unordered; the $j$ is special because it is repeated, and $i,k$ are distinct since $i$ comes from the first factor. Indeed, when $n=3$, the expansion $(X_{12}+X_{13}+X_{23})^2$ has six factors of the form $X_{ij}X_{jk}$, not one. Therefore, you should replace $\color{red}{\binom{n}3}$ with $n(n-1)(n-2)$.
