16. Variance of the number of matches. A deck of playing cards is laid out on the table (for example, in a row). On top of each card, a card from another deck is placed. Some of the cards may have matched. Find:

a) the expected value of the number of matches;

b) the variance of the number of matches.
Solution. Here, the plot of a well-known matching problem is used, but the question is not about probability, but about the expectation and variance of the number of matches. Surprisingly, this problem is easier to solve than finding the probability. Again, we will use indicators.

a) Let's number the pairs from 1 to $N$ (we do not know how many they are) in the order in which they lie on the table. Let the indicator $I_{k}$ be 1 if the two cards in the $k$-th pair are the same, and 0 if the cards in the $k$-th pair are different. Obviously, $\mathrm{P}\left(I_{k}=1\right)=\frac{1}{N}$. Therefore, $I_{k}$ has a Bernoulli distribution

$$
I_{k} \sim\left(\begin{array}{cc}
0 & 1 \\
\frac{N-1}{N} & \frac{1}{N}
\end{array}\right)
$$

The expected value is: $\mathrm{E} I_{k}=\frac{1}{N}$. The expectation does not depend on $k$.

Let $S$ be the number of pairs with a match. It is equal to the sum of the indicators:

$$
S=I_{1}+I_{2}+\ldots+I_{N}
$$

Transition to expectations: $\mathrm{E} S=\mathrm{E} I_{1}+\mathrm{E} I_{2}+\ldots+\mathrm{E} I_{N}=N \cdot \frac{1}{N}=1$.

b) Let's find the variance: $\mathrm{D} S=\mathrm{E} S^{2}-(\mathrm{E} S)^{2}=\mathrm{E} S^{2}-1$.

The difficulty lies in the expectation of $S^{2}$. We will slightly modify the same method we have already used:

$$
S^{2}=\left(I_{1}+I_{2}+\ldots+I_{N}\right)^{2}=I_{1}^{2}+I_{2}^{2}+\ldots+I_{N}^{2}+2\left(I_{1} I_{2}+I_{1} I_{3}+\ldots+I_{j} I_{k}+\ldots+I_{N-1} I_{N}\right)
$$

where in the parentheses is the sum of the pairwise products of all possible different indicators. To transition to the mathematical expectation, we need to find the distribution and expectation of the random variables $I_{k}^{2}$ and $I_{j} I_{k}$ for $k \neq j$.

The distribution of $I_{k}^{2}$, obviously, coincides with the distribution of $I_{k}: I_{k}^{2} \sim\left(\begin{array}{cc}0 & 1 \\ \frac{N-1}{N} & \frac{1}{N}\end{array}\right)$.

Therefore, $\mathrm{E} I_{k}^{2}=\frac{1}{N}$.

Now consider the quantity $I_{j} I_{k}$. It is 1 if the cards match in both the $j$-th pair and the $k$-th pair. The cards in the $j$-th pair match with probability $\frac{1}{N}$. If this happens, the probability of the cards matching in the $k$-th pair is $\frac{1}{N-1}$. Therefore,

$$
\mathrm{P}\left(I_{j} I_{k}=1\right)=\mathrm{P}\left(I_{j}=1 \cap I_{k}=1\right)=\mathrm{P}\left(I_{k}=1 \mid I_{j}=1\right) \cdot \mathrm{P}\left(I_{j}=1\right)=\frac{1}{N-1} \cdot \frac{1}{N}=\frac{1}{N(N-1)} .
$$

In all other cases, $I_{j} I_{k}=0$. We obtain the distribution

$$
I_{j} I_{k} \sim\left(\begin{array}{cc}
0 & 1 \\
1-\frac{1}{N(N-1)} & \frac{1}{N(N-1)}
\end{array}\right)
$$

from which: $\mathrm{E}\left(I_{j} I_{k}\right)=\frac{1}{N(N-1)}$.

Then

$$
\mathrm{E} S^{2}=N \cdot \mathrm{E} I_{k}^{2}+2 C_{N}^{2} \cdot \mathrm{E}\left(I_{j} I_{k}\right)=N \cdot \frac{1}{N}+2 C_{N}^{2} \cdot \frac{1}{N(N-1)}=1+1=2
$$

and, consequently, $\mathrm{D} S=2-1=1$.

Answer: a) $1 ;$ b) 1.

Comment. Surprisingly, neither the expectation nor the variance of the number of matches depends on the number of cards in the deck.