5

I was asked this question this time at lunch and could not stop thinking about it since then. I could not find the answer, so that's why I am asking here.

The story is as following: n people write their name on a card and put it in a box. After everyone has put their card with their name into the box, people will, one by one, grab a card. If a person takes a card with his/her own name, before that person puts his/her own card back in, that person takes another card (guaranteeing that he/she takes a different card now). After taking a different card, that person puts their own card back into the box.

So, the question is: what is the chance that the last person who grabs a card, is left with his own card?

We could, for example, take 31 persons in total, so n = 31.

Mike Voets
  • 51
  • 3
  • Similar question at http://math.stackexchange.com/q/876126/131263. – barak manos Dec 08 '14 at 10:00
  • @barakmanos So according to the last reaction in that thread, the second formula, the chance would be 50% is this case? – Mike Voets Dec 08 '14 at 10:08
  • Sorry, reading your question more carefully, it is slightly different from the one I've mentioned. There's something unclear with "put it back in, and take another". Is that person guaranteed to take a different card this time, or can he/she possibly take the same card that they've just returned? – barak manos Dec 08 '14 at 10:15
  • @barakmanos Okay - I will make it more clear. Let's say that, if a person takes a card with his/her own name, before that person puts his/her own card back in, that person takes another card (guaranteeing that he/she takes a different card now). After taking a different card, that person puts their own card back into the box. – Mike Voets Dec 08 '14 at 10:22
  • 1
    I have written a program to compute the probabilities for small $n$, and here are the results it produced: $1/4$ for $n=3$; $5/36$ for $n=4$; $19/144$ for $n=5$; $203/1800$ for $n=6$; $4343/43200$ for $n=7$; $63853/705600$ for $n=8$; $58129/705600$ for $n=9$; $160127/2116800$ for $n=10$. (The results for $n$ from $3$ to $5$ are the same as what I computed by hand, so the rest are probably correct as well.) So there does not seem to be a nice general answer. – Litho Dec 08 '14 at 13:41

2 Answers2

1

This may not be the type of solution you are looking for, but you can model this as a non-homogenous markov chain and then have Matlab or other numerical package compute the answers for you:

Lets say you have $N$ participants. You will need to create a $2^{N}-1$ state transition matrix for a Markov Chain. Each state can be coded as a binary string representing the available cards in the pile. For example, if $N=4$ then $5=0101$ represents the state where cards $1$ and $3$ have been taken already (i.e., we are on draw 3 of 4).

Using this informative coding scheme, we can set up this (admittedly large) transition matrix so that there is an equal probability of going from a state with $K$ cards to a state with $K-1$ cards, where each transition has probability $\frac{1}{K}$ (Note: transition probabilities are row-wise stochastic, so you start at a row and go to a column in the next state). There is $0$ probability of staying in the same state, going to a higher card state, or skipping to the $N-2$ card state.

Now that you have this transition matrix set up, lets pick an arbitrary "lineup" of participants. For simplicity, lets say the participants have numbers for names and they are standing in numerical order (e.g., Person 1 is first, Person 2 is second etc). By exchangability, the solution for this specific problem will be the same as for the general problem.

We now will create a series of $N$ "masks" for the transition matrix. Each mask is a matrix of the same size as the transition matrix but it contains only 1's or 0's for its elements. The mask for participant $i$ will have 1's everywhere except where the row state contains card $i$ and the column state does not (since they cannot choose themselves).

Now, you can create a sequence of matrices by multiplying, elementwise the transition matrix by a mask matrix. For example, the transition matrix for person $i$ will simply be the overall transition matrix multiplied by its mask. You then divide each row by the row sum to re-normalize.

The final step is to left multiply the above matrices for $i= 1 \to N-1$.

This is the $N-1$-step transition matrix for your problem. To get the specific solution, you want to right multiply by the column vector $(0,0....1)^T$, since you will be starting in a state with all the cards. The probability you seek is the probability of ending up in state $N=00000...1=1$ (since we assume the last person happens to be Person N).

Here's an example for 3 participants (so they will be choosing in order 1, 2, 3):

Our states are $111=7,110=6,101=5,100=4,011=3,010=2,001=1,$

the first row of the transition matrix will be for state $1$ to state $x$: $r_1=(1,0,0,0,0,0,0)$ (since the "single card states" are absorbing states). A similar row will be made for rows 2 and 4.

The first non-trivial row will be row 3: $r_3=(0.5,0.5,0,0,0,0,0)$, since you can only go from having two cards to having one card.

The other rows would be:

$r_5=(0.5,0,0.5,0,0,0,0),\;\;r_6=(0.5,0.5,0,0,0,0,0),\;r_7=(0,0,1/3,0,1/3,1/3,0)$

The above is our transition matrix (pardon the formatting couldn't get constant width).

$\begin{matrix}1,0,0,0,0,0,0\\0,2,0,0,0,0,0\\0.5,0.5,0,0,0,0,0\\0,0,0,1,0,0,0\\0.5,0,0.5,0,0,0,0\\0.5,0.5,0,0,0,0,0\\0,0,1/3,0,1/3,1/3,0\end{matrix}$

The masks will be:

Mask 1:

$\begin{matrix}1,1,1,1,1,1,1\\1,1,1,1,1,1,1\\1,1,1,1,1,1,1\\0,0,0,1,1,1,1\\0,0,0,1,1,1,1\\0,0,0,1,1,1,1\\0,0,0,1,1,1,1\end{matrix}$

Mask 2:

$\begin{matrix}1,1,1,1,1,1,1\\0,1,1,0,0,1,1\\0,1,1,0,0,1,1\\1,1,1,1,1,1,1\\1,1,1,1,1,1,1\\0,1,1,0,0,1,1\\0,1,1,0,0,1,1\end{matrix}$

Mask 3:

$\begin{matrix}1,0,1,0,1,0,1\\1,1,1,1,1,1,1\\1,0,1,0,1,0,1\\1,1,1,1,1,1,1\\1,0,1,0,1,0,1\\1,1,1,1,1,1,1\\1,0,1,0,1,0,1\end{matrix}$

An example of the revised matrix would be:

Using mask 1 ($T_1$):

$\begin{matrix}1,0,0,0,0,0,0\\0,2,0,0,0,0,0\\0.5,0.5,0,0,0,0,0\\0,0,0,1,0,0,0\\0,0,0,0,0,0,0\\0,0,0,0,0,0,0\\0,0,0,0,1/2,1/2,0\end{matrix}$

You'd left multiply the above matrices in order (i.e,$T_3T_2T_1$), then right multiply by $(0,0,0,0,0,0,1)^T$ and read off the value in the first element of the resultant vector to get your answer.

Sorry this is so long, but the above should give a systematic way to model and calculate the probabilities.

0

Let $S_n$ be the set of permutations on $ \\{1,...,n\\} $.

The sample space is the set of all the orders in which people's cards may be taken. We can identify it with the set $\Omega = \{\sigma \in S_n \mid \sigma(k) \neq k \text{ for all } 1\leq k \leq n-1 \}$.

The event that the last person takes his own card is the set $E = \{\sigma \in \Omega \mid \sigma(n) = n\} $.

The outcomes are chosen uniformly among all the permutations in $\Omega$. Hence $\mathrm{P}(E) = \dfrac{|E|}{|\Omega|}$.

We can compute both |$\Omega|$ and $|E|$ using the inclusion-exclusion principle.

Let $A_k = \{\sigma \in S_n \mid \sigma(k) = k\} $, i.e. the set of permutations which fix $k$. Then $\Omega = S_n \setminus (A_1 \cup \dots \cup A_{n-1})$ so $|\Omega| = n! - |(A_1 \cup \dots \cup A_{n-1})|$. Applying inclusion-exclusion, we have

\begin{align*} |A_1 \cup \dots \cup A_{n-1}| &= \sum_{1\leq i \leq n-1} |A_i| \newline &- \sum_{1\leq i < j \leq n-1} |A_i \cap A_j| \newline &+ \sum_{1\leq i < j < k \leq n-1} |A_i \cap A_j \cap A_k| \newline &- \dots \newline &+ (-1)^n |A_1 \cap \dots \cap A_{n-1}| \end{align*}

This sum has $n-1$ terms. The $m$-th term counts the number of subsets which fix at least $m$ of the first $n-1$ integers. There are $\binom{n-1}{m}$ ways to choose these $m$ integers and $(n-m)!$ ways to order the remaining ones. Thus the $m$-th term equals $\binom{n-1}{m} (n-m)!$ and we have \begin{equation*} |A_1 \cup \dots \cup A_{n-1}| = \sum_{m=1}^{n-1} (-1)^{m+1} \binom{n-1}{m} (n-m)! \end{equation*}

Putting this together we have \begin{align*} |\Omega| &= n! - |(A_1 \cup \dots \cup A_{n-1})| \newline &= n! - \sum_{m=1}^{n-1} (-1)^{m+1} \binom{n-1}{m} (n-m)! \newline &= n! - (n-1)! \sum_{m=1}^{n-1} (-1)^{m+1} \frac{n-m}{m!} \newline &= (n-1)! \left(n - \sum_{m=1}^{n-1} (-1)^{m+1} \frac{n-m}{m!}\right) \newline &= (n-1)! \sum_{m=0}^{n-1} (-1)^m \frac{n-m}{m!} \end{align*}

$|E|$ can be computed along similar lines. As a shortcut, we may observe that each permutation $\sigma \in E$ is uniquely determined by a derangement on $ \\{1,\dots,n-1\\} $, and hence use the formula for the number of derangements on $n-1$ elements (which is derived from the same method): \begin{align*} |E| &= \sum_{m=0}^{n-1} (-1)^m \binom{n-1}{m} (n-1-m)! \newline &= (n-1)! \sum_{m=0}^{n-1} (-1)^m \frac{1}{m!} \newline \end{align*}

Finally we arrive at the probability that the last person takes his own card, \begin{equation*} \mathrm{P}(E) = \frac{|E|}{|\Omega|} = \frac{\displaystyle \sum_{m=0}^{n-1} (-1)^m \frac{1}{m!}}{\displaystyle \sum_{m=0}^{n-1} (-1)^m \frac{n-m}{m!}} \end{equation*}

The first few values for $n=1,2,\dots$ are $1, 0, \frac{1}{3}, \frac{2}{11}, \frac{9}{53}, \dots$.