Problem

Example (Variance of the Number of Matches)
A group of N people throw their hats into the center of a room. The hats are mixed up, and each person randomly selects one. Find the variance of X, the number of people that select their own hats.
Solution:
Using the same representation for $X=X_1+\cdots+X_N$ where
$X_i=\left\{
\begin{array}{rcl}
1&\mbox{ if }i\mbox{th man selects his won hat } \\ \\
0&\mbox{ otherwise }
\end{array}\right .$
we have that
$Var(X)=\displaystyle\sum{i=1}^NVar(X_i)+2\sum\sum_{\hspace{-0.5cm}i<j}Cov(X_i,X_j)
\qquad (3.2)$
Since $P\{X_i=1\}=1/N$, we have
$Var(X_i)=\displaystyle\frac{1}{N}\left (1-\frac{1}{N}\right )=\frac{N-1}{N^2}$
Also,
Cov(Xi,Xj)=E[XiXj]-E[Xi]E[Xj]
Now,
$X_iX_j=\left\{
\begin{array}{ll}
1&\mbox{ if the }i\mbox{th and }j\mbox{th men both select their own hats} \\ \\
0&\mbox{ otherwise }
\end{array}\right .$
and thus
$\begin{array}{rcl}
E[X_iX_j]&=&P\{X_i=1,X_j=1\} \\ \\
&=&P\{X_i=1\}P\{X_j=1\vert X_i=1\} \\ \\
&=&\displaystyle\frac{1}{N}\frac{1}{N-1}
\end{array}$

Hence,

$Cov(X_i,X_j)=\displaystyle\frac{1}{N(N-1)}-\left (\frac{1}{N}\right )^2
=\frac{1}{N^2(N-1)}$
and from Equation (3.2),
$\begin{array}{rcl}
Var(X)&=&\displaystyle\frac{N-1}{N}+2{N\choose 2}\frac{1}{N^2(N-1)} \\ \\
&=&\displaystyle\frac{N-1}{N}+\frac{1}{N} \\ \\
&=&1
\end{array}$

Thus both the mean and variance of the number of matches are equal to 1. When N is large, the probability of i matches is approximately e-1/i!. That is, when N is large, the number of matches is approximately distributed as a Poisson random variable with mean 1. Hence, as the mean and variance of a Poisson random variable are equal.