# Does the likelihood of getting a certain person in secret santa decrease if you were going first versus going last, and how much?

Feeling a bit stupid but here goes:

There are 6 people in this secret Santa thing, one of them is person X and another is person Y. All the names are put into a hat and each person comes up to take a name from the hat. If the name is their own, they put it back and redraw until it is someone else's name. Then, the next person goes and does the same. Drawn names are not replaced.

What are the chances person X gets person Y's name if they go first? And what are the chances that person X gets person Y's name if they go last?

Thanks for your help in advance, it's embarrassing how much this is wracking my brain

• What happens if the last person draws their own name?
– Stef
Commented Dec 6, 2023 at 14:33
• From X's perspective, all non-X people are exchangeable. Therefore the chance of getting any name at any specified stage is $1/(6-1).$
– whuber
Commented Dec 6, 2023 at 15:22

#### Prior probabilities

There is one problem with the algorithm: it is possible that the last person will draw their own name, in which case they can't put it back and draw another name.

One simple way to fix the algorithm is to say: if the last person draws their own name, then we forget everything and restart from the beginning, i.e., everyone puts the names back in and we restart again. The probability that this will happen is exactly 1 divided by the number of participants, so 1/6 ≈ 17%.

With that fix, the algorithm produces a uniformly-random derangement. So the chance that X will draw Y's name is exactly 1 out of 5, or 20%, no matter whether X is first or second or last to draw.

#### Conditional probabilities

However, if you observe the drawings as they happen, then you gain new information. If the third person to draw a name draws their own name and has to put it back in the hat, then you learn that their name is still in the hat. If the third person to draw a name doesn't put the name back in the hat, then you don't learn for sure whether their name is still in the hat or not, but the conditional probability that their name is still in the hat, knowing that they didn't draw their own name, is slightly lower. These observations affect the conditional probabilities of the draws of the fourth, fifth and sixth drawers.

This means that you can calculate conditional probabilities for the probability that X has drawn Y's name, given what you've observed. These conditional probabilities will not be exactly equal to 1 out of 5, or 20%.

One particular extreme is the case where Y is second-to-last to draw a name, and X is last to draw a name, and you observe that Y has drawn their own name and put it back. Y draws another name, and at this point you know that the only name remaining in the hat is Y, so you know that X draws Y with probability 1, or 100%.

These conditional probabilities are not particularly easy to calculate in general, but given that there are only 6 participants, there are only 265 possible derangements, so it's easy to compute these conditional probabilities with a computer program. You could write a simple computer program that enumerates all possible scenarios and counts the number of scenarios that match your observations, and counts the number of scenarios that match your observations in which X draws Y, and returns the ratio of these two counts.

EDIT: After some additional thoughts, it turns out that this computer program is not as straightforward as I thought. I will think some more.

• Here is R code to compute an array of all derangements: draw <- function(p, x) sapply(p, \(i) {y <- x[i]; x <<- x[-i]; y}); P <- do.call(expand.grid, lapply(rev(seq_len(6)), seq_len)); D <- apply(P, 1, draw, seq_len(ncol(P))); D <- D[, apply(D, 2, \(x) all(x != seq_len(nrow(D))))] Using this you can tabulate any conditional probabilities you want. But I don't believe the question is asking about them: it asks about probabilities, period, which ordinarily would mean unconditional probabilities before the drawing begins.
– whuber
Commented Dec 6, 2023 at 16:52
• @whuber Thanks. Actually my "EDIT:" comment was due to the realisation that my last sentence was incorrect, ie the ratio (count of derangements that are feasible given the observations and in which X draws Y) / (count of derangements that are feasible given the observations) is not equal to the conditional probably P(X draws Y | observations).
– Stef
Commented Dec 6, 2023 at 17:22
• I decided to include both unconditional and conditional probabilities in my answer for a few reasons: 1) Some people never use the expression "conditional probabilities", simply because they don't know about it; 2) Some people's confusion arises specifically because they don't have the vocabulary to make the distinction between unconditional and conditional probabilities; 3) If someone really does participate in such a drawing procedure, and does witness the drawing, they can't "forget" what they've seen, so not mentioning the conditional probabilities, knowing what they know, seems wrong.
– Stef
Commented Dec 6, 2023 at 17:29
• Thank you for the clarification.
– whuber
Commented Dec 6, 2023 at 17:45