
(Note: originally, this article was written using Mathematica, a computer algebra package. Unfortunately, the conversion from Mathematica’s native display format to HTML did not work properly, so the text had to be transferred by copy and paste, and the calculation inputs and outputs had to be done “by hand” where possible, and by conversion to bitmap where not. Apologies for the resulting confused appearance.)
A group of friends take part in a game of Secret Santa at Christmas. There are n people taking part.
What is the probability that m pairs of people will have each other as their Secret Santa?
The way to tackle this question is to find the probability that m particular pairs of people will have each other as their secret Santa, then multiply that probability by the number of possible groups of m pairs. A pair of people that have each other as their Secret Santa is called a reciprocating pair.
First we need to find the probability of finding one matching pair of people in a group of n friends. Let’s start by imagining that there are 5 friends taking part: Dave, John, James, Jane and Erica. What’s the probability of finding a reciprocating pair?
Well, we need one person to pick someone, who goes on to pick him or her in return:
This is 1/4 x 1/4 = 1/16.
This works because there is a 1 in 4 chance of say Dave picking John (he can’t pick himself), and a corresponding 1 in 4 chance of John picking Dave.
In general, for n people, the probability is 1 in (one less than the number of people taking part), multiplied by itself.
This is 1/(n-1)^2
The probability that a further pair will have each other must now be calculated from the remaining people. In our example, we are down to James, Jane and Erica, which means that the number of reciprocating pairs is 3 x 2 = 6. In general though, we now have two fewer people than we did before to choose from. That’s n – 2 people. Using the rule that a particular person can’t pick him or herself, we can calculate the probability of a second match as
1/((n-2) – 1)^2 or 1/(n – 3)^2
The probability of a third match is calculated using the fact that we now have two fewer people to choose from again, or n – 4 people. This gives us 1/((n-4) – 1)^2 or 1/(n – 5)^2.
The probability of an mth match can be found by glancing at the numbers after n in the denominator of each fraction. You can see that they form a sequence 1,3,5,… The position-to-term rule for a sequence of this type is 2m – 1, where m is the number of the match. This is 1/(n – (2m – 1))^2.
To find the probability of a particular three pairs matching in Secret Santa, you just multiply the probabilities of a first, a second and a third match together.
For a game with 11 people (i.e. n = 11) this works out to 1/230400.
This low figure means that for an eleven person game, the probability of a particular three pairs matching, say Amy – Bill, Charles – Derren, and Emily – Fred is vanishingly small.
What about the probability of a particular m pairs matching? To calculate this, we need the probability of the mth pair matching, which we already know is 1/(n – (2m – 1)^2, and then multiply it by the (m -1)th probability, and the (m -2)th probability, and so on until we come to m = 1.
To do this, we use the product function, which multiplies its terms together in a way analogous to the sum function ∑. Here, the range variable is i.
∏ 1/(n – (2i -1))^2 (evaluated from i = 1 to m)
We are half-way to a general formula. We now need to know the number of possible groups of m particular reciprocating pairs chosen from n people. This is easier than it seems. The way to count the number of pairs in n people is n(n-1). Look at the possible pairs for our original 5 people: Dave, John, James, Jane, and Erica.
Dave – John
Dave-James
Dave-Jane
Dave-Erica
John-Dave
John-James
John-Jane
John-Erica
James-Dave
James-John
James-Jane
James-Erica
Jane- Dave
Jane- John
Jane-James
Jane-Erica
Erica-Dave
Erica-John
Erica-James
Erica-Jane
Looking in the left column, you can see that each of the five names appears, and is matched with everyone else except themselves. This means each person is matched with four others. That is why the formula for possible pairs is the number of names multiplied by one less than this number: n x (n – 1). In our particular case of 5 names, there are 5 x 4 = 20 possible pairs. Of course, to get a reciprocating pair Jane-John and John-Jane must be combined – Jane buys for John and John buys for Jane. This means the number of reciprocating pairs is half the number of possible pairs. The formula now becomes (1/2)n(n – 1).
Having matched up two people, they are removed from the group, which now has n – 2 members. We then count the possible pairs again. The formula for the next set of pairs is therefore (1/2)(n – 2)(n – 3).
We have n – 4 players left, so the formula is (1/2)(n – 4)(n – 5) and so on. To find the total number of groups consisting of three reciprocating pairs out of n people, we simply multiply our three formulae together:
(1/2)n x (n – 1) x (1/2)x (n – 2) x (n – 3) x (1/2) x (n – 4)(n – 5). For 11 people this is
(1/2) x 11 x 10 x (1/2) x 9 x 8 x (1/2) x 7 x 6 = 41580.
For n people, we use another product formula:
∏((1/2)
x (n – 2i) x (n – (2i+1)) (evaluated from i = 0 to m – 1)
Using Mathematica, we can now combine the formula for m particular matches with the formula for m possible groups out of n people:

This gives us

The Pochhammer function takes inputs n and m and evaluates
according to the rule
It is related to the factorial function.
Finally, we define a function whimsically called SecretSanta, which takes inputs n and m and gives us the probability of finding m reciprocating pairs in n people.

For n = 11 and m = 3 the output is given below.
SecretSanta[11, 3]
0.180469
Or an 18% chance that there will be three matching reciprocating pairs.
This 3D visualisation shows how the probability of any number of matches falls off quite dramatically with rising numbers of people taking part.
