Probability – General Expression for Probability of a Failed Gift Exchange Draw

combinatoricsderangementsprobability

My family does a gift exchange every year at Christmas. There are five couples and we draw names from a hat. If a person draws their own name, or the name of their spouse, all the names go back in a hat and we re-draw names. This happens maybe 7 times out of 8.

Using a computer, I know that the probability of this happening is

1 - (440192 / 10!)

or about 88%.

(It's been too long since I took combinatorics) What's a general expression for n couples?

Edit Oct 19, 2011: I was so impressed with the answer, I wrote a blog post about it: http://michaeljswart.com/2011/10/secret-santa-as-a-puzzle/

Best Answer

By assigning a letter to each couple, this can be reduced to the problem of finding the number $a_n$ of anagrams of a word with $n$ different letters, each occurring twice, with no letters fixed. The desired number of permutations is then $2^na_n$, since each of the $n$ couples can be assigned in two ways to the two instances of its letter. Wikipedia mentions this problem as a generalized derangement problem. The general formula given for a word with numbers $n_1,\dotsc,n_r$ of $r$ different letters is

$$\int_0^\infty L_{n_1}(x)\cdots L_{n_r}(x)\mathrm e^{-x}\mathrm dx\;,$$

where $L_k(x)$ is the $k$-th Laguerre polynomial. In the present case, $r=n$ and $n_i=2$, so we only need the second Laguerre polynomial, which is $L_2(x)=\frac12(x^2-4x+2)$. The $n$ factors of $\frac 12$ cancel with the $n$ factors of $2$, so the probability of success is

$$\frac1{(2n)!}\int_0^\infty\left(x^2-4x+2\right)^n\mathrm e^{-x}\mathrm dx\;,$$

where $(2n)!$ counts the total number of permutations. For $n=5$, Wolfram|Alpha gives $440192/(10!)$, as you calculated.

We can also recover Ross' estimate $\mathrm e^{-2}$ from this result in the limit $n\to\infty$:

$$ \begin{eqnarray} \frac1{(2n)!}\int_0^\infty\left(x^2-4x+2\right)^n\mathrm e^{-x}\mathrm dx &=& \frac1{(2n)!}\int_0^\infty\left((x-2)^2-2\right)^n\mathrm e^{-x}\mathrm dx \\ &\approx& \frac1{(2n)!}\int_2^\infty\left((x-2)^2-2\right)^n\mathrm e^{-x}\mathrm dx \\ &=& \frac{\mathrm e^{-2}}{(2n)!}\int_0^\infty\left(x^2-2\right)^n\mathrm e^{-x}\mathrm dx \\ &=& \frac{\mathrm e^{-2}}{(2n)!}\int_0^\infty\sum_{k=0}^n\binom nk(-2)^kx^{2(n-k)}\mathrm e^{-x}\mathrm dx \\ &=& \frac{\mathrm e^{-2}}{(2n)!}\sum_{k=0}^n\binom nk(-2)^k\int_0^\infty x^{2(n-k)}\mathrm e^{-x}\mathrm dx \\ &=& \frac{\mathrm e^{-2}}{(2n)!}\sum_{k=0}^n\binom nk(-2)^k(2(n-k))! \\ &=& \frac{\mathrm e^{-2}}{(2n)!}(2n)!\left(1-\frac1{2n-1}+\dotso\right) \\ &\approx& \mathrm e^{-2}\;. \end{eqnarray} $$

Related Question