# Expectation and Variance of Card Pairs

A 26 card deck containing 13 "hearts" and 13 "spades" is well-shuffled. Thirteen pairs are then dealt from the deck. A pair is a "match" if it contains 1 heart and 1 spade. Let N be the number of matches. The deck will always be exhausted in each dealing, so you will always have 13 pairs. What is the expectation and variance of N?

N will always have be an odd number because you have 13 of each card, and the median of N is 7, so that's my educated guess for expectation. Beyond that, however, I'm not sure of how to approach this problem.

• I don't see that N is well defined? Are you drawing pairs until the deck is exhausted? – Michael R. Chernick Dec 14 '17 at 0:34
• Yes, all cards are paired until the deck is exhausted, so you will always have 13 "pairs" of cards. – BenL126 Dec 14 '17 at 0:36
• That is what I thought but it needs to be stated in the question. – Michael R. Chernick Dec 14 '17 at 0:37

## Expected Value

The Expected Value can be solved easily using Linearity of Expectation. Define $$X_i = \begin{cases} 1, & \text{ if the i^{th} pair is a match} \\ 0, & \text{ otherwise} \end{cases}$$

It should be clear that, with this set up, we have $N = \sum_{i=1}^{13} X_i$.

Next we find $P(X_i = 1)$. Without loss of generality, assume that the first card is a heart which implies that there are $12$ hearts and $13$ spades remaining. Thus $P(X_i = 1) = \frac{13}{12+13} = 0.52$. In turn, we have $E(X_i) = 0(0.48) + 1(0.52) = 0.52$.

Now via Linearity of expectation, $$E(N) = E\left(\sum_{i=1}^{13}X_i\right) = \sum_{i=1}^{13}E(X_i) = \sum_{i=1}^{13}0.52 = 6.76$$

## Variance

The calculation for variance is somewhat more involved. Since the $X_i$ are not independent we have,

$$Var(N) = Var\left(\sum_{i=1}^{13}X_i\right) = \sum_{i=1}^{13}Var(X_i) + 2\sum_{i\neq j}Cov(X_i, X_j)$$

First note that $Var(X_i) = (0.52)(0.48)$ (by recognizing that $X_i \sim Bern(0.52)$). To find the covariance of term, we start with $$Cov(X_i, X_j) = E(X_iX_j) - E(X_i)E(X_j)$$ The only new term here is $E(X_iX_j)$. With a little bit of thought, you should be able to convince yourself that $$E(X_iX_j) = P(X_i=1, X_j=1) = P(X_i=1|X_j=1)P(X_j=1)$$ We now focus on the term $P(X_i=1|X_j=1)$. In simpler terms (wlog), we are looking for "the probability the second pair is a match given that the first pair is a match." By similar logic to above, we have, $$P(X_i=1|X_j=1) = \frac{12}{11+12} = \frac{12}{23}$$.

Finally, we put all of the pieces together.

\begin{align*} Var(N) &= \sum_{i=1}^{13}Var(X_i) + 2\sum_{i\neq j}Cov(X_i, X_j) \\ &= 13(.52)(.48) + 2\binom{13}{2}\left[\frac{12}{23}(0.52) - (0.52)^2\right] \\ &= 3.385878 \end{align*}

## Verification via Simulation

These answers can be easily checked in R

M <- 10000
count <- rep(0, M)
for(m in 1:M){
deck <- c(rep(0, 13), rep(1,13))
shuffle <- sample(deck, replace=F)
for(i in seq(1,26,by=2)){
if(shuffle[i]!=shuffle[i+1])
count[m] <- count[m] + 1
}
}


Running this simulation, mean(count) returns $6.76004$ and var(count) returns $3.396853$.

• Thank you very much for your detailed response! For the expected value, why is the expectation 0.52 for the ith pair? It seems to me that as you deal more cards the probabilities change, so 0.52 would only be true for the first pair of cards dealt. – BenL126 Dec 14 '17 at 6:01
• That is true. What you are saying shows that the $X_i$ are NOT independent of eachother. Marginally however (ignoring other information), we can do the same calculation for any particular pair. Since linearity of expectation "doesn't care" about independence the result will hold. – knrumsey Dec 14 '17 at 7:22
• Thank you for pointing out that it's the marginal probabilities that are not changing. I have one last question, if that's alright. When calculating $E(X_iX_j)$, why does the first equality hold? I've not seen expectation converted to a probability quite like that. – BenL126 Dec 15 '17 at 18:27
• Thats subtle and I skipped the details. Since $X_i$ are binary, the product is also binary. Hence $$E(X_iX_j) = 1P(X_iX_j = 1) + 0P(X_iX_j = 0) = P(X_iX_j=1) = P(X_i = 1, X_j = 1)$$ – knrumsey Dec 15 '17 at 19:21