What is the expected number of runs of same color in a standard deck of cards?

Standard deck has $52$ cards, $26$ Red and $26$ Black. A run is a maximum contiguous block of cards, which has the same color.

Eg.

  • $(R,B,R,B,...,R,B)$ has $52$ runs.
  • $(R,R,R,...,R,B,B,B,...,B)$ has $2$ runs.

What is the expected number of runs in a shuffled deck of cards?


The expected number of runs is 27.

Let $X_n$ be the color of the n'th card. For n<52, the n'th card is the end of a run if and only if $X_n\not=X_{n+1}$ and the last card in the pack is always the end of a run. So, the total number of runs is $$ N=\sum_{n=1}^{51}1_{\{X_n\not=X_{n+1}\}}+1. $$ The expected number of runs is $$ \mathbb{E}[N]=\sum_{n=1}^{51}\mathbb{P}(X_n\not=X_{n+1})+1. $$ Whatever colour the n'th card is, there are 51 remaining cards in the deck of which 26 of them are a different colour from $X_n$. So, $\mathbb{P}(X_n\not=X_{n+1})=26/51$, giving $$ \mathbb{E}[N]=51 (26/51) + 1=27. $$


Note: This solution works because of the happy "coincidence" that the number of ways to get $k$ runs is the same as the number of ways to get $2n+2 - k$ runs. We will prove that first, then apply it.

Lemma: The number of ways to achieve $k$ runs is $ 2 \times { n-1\choose \lceil \frac{k}{2} \rceil-1} \times { n-1 \choose \lfloor \frac{k}{2} \rfloor - 1 }$.

Proof: A sequence of $k$ runs can be defined as having $a_1$ of the first color, $b_1$ of the second color, $a_2$ of the first color, $b_2$ of the second color, so on and so forth. For the final term, if $i$ is odd, we have $a_{ \lceil \frac{k}{2} \rceil }$ of the first color, and if $k$ is even, we have $b_{\lfloor \frac{k}{2} \rfloor}$ of the second color.

After choosing what the first color is, we have the constraint that $ \sum a_i = n$ and $ \sum b_i = n$, of which there are $ \lceil \frac{k}{2} \rceil $ terms in the first summation and $ \lfloor \frac{k}{2} \rfloor$ terms in this second summation. It is easy to see that this is the only constraint, since given any 2 such summations, we can form a sequence of $i$ runs. This establishes the bijection between a sequence of $k$ runs and solutions to these equations.

We now count the number of ways to get such solutions. By bars and stars, there are $ { n-1 \choose \lceil \frac{i}{2} \rceil - 1 } $ solutions to the first equation, and ${ n-1 \choose \lfloor \frac{i}{2} \rfloor - 1 }$ solutions to the second. Hence the lemma follows.

Corollary: Given $2n$ cards, the number of ways to get $r$ runs is the same as the number of ways to get $2n+2-r$ runs.

Corollary: By symmetry, the expected number of runs is $ \frac{ r + ( 2n+2 - r ) } { 2 } = n+ 1 $.