Variance of number of matchs in a deck of card

probabilityrandom variablesvariance

Consider we have a shuffled deck of $n$ cards numbered $1 , . . . , n$. We say we have a match if card number $i$ be in position $i$ . example in sequence $1,4,3,2,5$ we have $3$ matches. Suppose $X$ be a random variable indicating number of matches in a deck of $n$ cards. How to calculate $Var(X)$ ?

Best Answer

Hint: Let $I_i$ be the indicator random variable for the event "card $i$ is in position $i$." (That is, $I_i = 1$ if the event holds, and $I_i=0$ otherwise.) Then $X = I_1 + \cdots + I_n$. Then, $$\text{Var}(I_1 + \cdots + I_n) = \sum_{i=1}^n \text{Var}(I_i) + \sum_{i=1}^n \sum_{j \ne i} \text{Cov}(I_i, I_j),$$ and compute each term separately. If you don't want to use this formula (don't know what covariance is, etc.), instead do $\text{Var}(X) = E[X^2] - E[X]^2$ and compute $E[(I_1 + \cdots + I_n)^2]$ and $(E[I_1 + \cdots + I_n])^2$ by expanding.

Related Question