4 Prisoners

The end of the 100 Prisoners post asked if there is a way to show that there does not exist a strategy that meets the coupon collector lower bound for release when there are $N > 3$ prisoners.

Let’s first establish strategies for $N \leq 3$. Note that for $N = 1$, the prisoner can declare victory on the first day, which trivially meets the coupon collector lower bound. Similarly, for $N = 2$, the first time a new prisoner enters after the first day, the prisoner can declare victory since there is only one other prisoner, who entered on the first day. Again, this trivially meets the coupon collector bound.

For $N = 3$, we actually need to use the light switch. On day 1, the first prisoner turns the light switch off. The next new prisoner (second prisoner) to enter turns the light switch on. The next new prisoner (third prisoner) to see the light switch on declares victory. Once again, this meets the coupon collector lower bound.

Why don’t we have luck for $N = 4$? We can arrive at it by contradiction: suppose there is a strategy that meets the coupon collector lower bound. Note that this requires the fourth prisoner to be able to determine based on the time of first entry and by looking at the light bulb whether or not he is the fourth prisoner. Without the light switch, all a new prisoner knows for any time $t \geq 4$ days is that he is not the first prisoner. Thus, if such a strategy should work, for $t \geq 4$, the light switch should uniquely identify whether or not three other prisoners have visited the room or not.

Without loss of generality, for $t \geq 4$, the switch will be on if and only if three of the prisoners have visited the room already. Suppose a prisoner enters the room for the first time on some day $t \geq 4$. If the light switch is off, then the prisoner must set the switch for the next day. However, the only information available to the prisoner is $t$ and the position of the switch, which indicates that either one or two prisoners have visited the room previously. If the prisoner sets the switch to on, and only one prisoner had visited the room before, the switch was set incorrectly. On the other hand, if the prisoner sets the switch to off, and two prisoners had visited the room before, the switch was also set incorrectly. Thus, we have arrived at a contradiction, and no strategy can achieve the coupon collector lower bound. Calculating an expected lower bound based on this argument and extending the argument to all $N > 3$ are left as exercises.

While the above argument indicates that the coupon collector lower bound is not tight for $N = 4$, it does not say whether the strategy given in the previous post is the best one can do. In fact, it is not, and what follows is a better strategy. Now, the light switch is used to indicate whether there have been an even or odd number of visitors to the room. The first visitor to the room switches it on, and on any prisoner’s first visit to the room thereafter changes the state of light switch:

1st prisoner changes the switch to ‘on’
2nd prisoner enters for the first time with the switch ‘on’ and changes it to ‘off’
3rd prisoner enters for the first time with the switch ‘off’ and changes it to ‘on’
4th prisoner enters for the first time with the switch ‘on’ and changes it to ‘off’

Note that since the third prisoner is only person to see the light switch off on his first time in the room, he can uniquely identify that there is only one prisoner left, and the next time he enters the room and sees the switch is off, he can declare victory. Likewise, if the first or second prisoner reenter the room after the third prisoner and before the fourth prisoner, then he can also figure out that there is only one prisoner left and can declare victory the next time he sees the switch off. It turns out the probability that both of them visit, which results in an expected time to release of

4/3 + $\mathbb{E}$ [coupon collector],

is 1/3; the probability only one of then visits, which results in an expected time to release of

2 + $\mathbb{E}$ [coupon collector],

is 1/3; and the probability that neither visits, which results in an expected time to release of

4 + $\mathbb{E}$ [coupon collector],

is 1/3. Thus, the expected time to release is $\frac{22}{9} + \mathbb{E}$ [coupon collector], where $\mathbb{E}$ [coupon collector] $= \frac{25}{3}$. This drops the expected time after coupon collector from $12$ to about $2.4$. Of course, we are taking advantage of the the fact that the number of prisoners is so small. I suspect it will be more difficult to make such pronounced improvements over the earlier strategy for larger $N$.

Shannon Meets Shannon

He’s met almost everyone else: Wiener, BodeBellmanCarnot, Tesla, Marconi, and of course, Shortz. Bad jokes aside, in an attempt to understand the inverse water filling solution from rate-distortion theory better, I put together some rough notes attempting to connect it and the sampling theorem. It’s kind of old school but makes an interesting exercise for students of information theory and signal processing. There are almost certainly places in the notes where the descriptions could be stated better, and I haven’t thoroughly scrubbed it for typos, so any feedback is both welcomed and encouraged.

sampling-inverse-water-filling v1.0

Posted in Information Theory, Signal Processing | 1 Comment

100 Prisoners

100 prisoners are condemned to life in prison, or so they think. One day the warden assembles all of the prisoners together and offers them a deal: “Starting tomorrow, I will select a prisoner at random every day and send him to a room with a lightbulb and switch. The prisoner may choose to turn the light on or off and must then leave. Now, here’s the deal: if, after visiting the room, a prisoner is convinced that all other prisoners have visited the room at least once, he may say so. If he is right, you will all be freed. If he is wrong, you will all be executed. After tonight, you will not be able to see or contact each other ever again, so devise a strategy now.” Morbidness aside, what strategy can the prisoners devise that guarantees their freedom?

After a friend first posed it to me, I’ve reasked this to several people over the years. Most who come up with a solution leave it that, but my uncle was not one of them.

“It’s going to take them too long to get out,” he noted. I sympathized, but somehow I wasn’t convinced there was a better solution, either.

Before getting to that solution and the time to release, how long would it actually take for the all the prisoners to visit the room at least once? The answer lies in the coupon collector’s problem. Given $N$ prisoners, the time $T$ for all of them to visit the room at least once can be expressed as the sum of geometric random variables $T = T_1 + T_2 + \cdots T_N$, where $T_i$ is the time for $i$th new person to enter the room after the $i-1$th new person has been there. By linearity of expectation, the expected time for all prisoners to visit the cell at least once can then be expressed as follows:

$\mathbb{E}[T] = \sum_{i=1}^N \mathbb{E}[T_i] = \sum_{i=1}^N \frac{N}{N+1-i} = N \cdot \sum_{i=1}^N \frac{1}{i} ~.$

For $N = 100$, $\mathbb{E}[T] \approx 519$ days, so the expected time for everyone to visit the room at least once would be less than two years.

Now what about for our solution? First, what was our solution? It works as follows. The person who enters on the first day becomes the monitor, who is the only one allowed to turn the light switch off. Everyone else is allowed either to turn the switch on or leave it as is. The goal is for the monitor to count the number of people who have visited the room at least once by the number of times he enters the room and the switch is on. To do this, the remaining prisoners follow the following protocol: if the prisoner has never turned the switch on and sees it off, he turns it on; otherwise, he leaves it as is. This protocol prevents the monitor from overcounting the number of prisoners who have. Thus, once the monitor has entered the room with the switch on $N-1$ times (the monitor can ignore his first visit and automatically count himself), he can claim with certainty that each prisoner has visited the room at least once. However, once a switch is turned on, prisoners who have yet to visit the room must wait until the monitor visits the room again before they are allowed to indicate their entry, thereby delaying the monitors final announcement.

How long exactly does it take? Again, we can proceed by a sum of geometric random variables. Let $U$ be the day the monitor announces every prisoner has been to the room at least once, which we express as the sum

$U = T_1 + V_1 + M_1 + V_2 + M_2 + \cdots + V_{N-1} + M_{N-1}$.

Here, $M_i$ represents number of days between the $i$th time light is turned on, and the monitor’s next visit to the room. This is a geometric random variable with expectation $\mathbb{E}[M_i] = N$. Similarly, $V_i$ represents the number of days between the monitor’s last visit and the $i$th prisoner that can turn on the switch for the first time. This is a geometric random variable with expectation $\mathbb{E}[M_i] = \frac{N}{N - i}$. Finally, $T_1$ is defined as before, and it is clear that $T_1 = 1$ day since whoever enters on the first day is automatically a first-time visitor to the room. By linearity of expectation, the expected time for the prisoners’ release is given as follows:

$\mathbb{E}[U] = N \cdot \sum_{i=1}^N \frac{1}{i} + N \cdot (N-1)~.$

For $N = 100$, $\mathbb{E}[U] \approx 10,419$ days, which is over 28 years! By that time, the warden will likely have retired and been replaced by a new warden who doesn’t respect the deal.

I have a bit more to say about the problem, but for now, I’ll leave you with a couple problems to consider.

1. Show that for $N > 3$, there exists no strategy for which the expected time to release is equal to the expected time to collect $N$ coupons.
2. Find a nontrivial lower bound in terms of $N$ for the minimum expected time to release.
Posted in Probability, Puzzle | 3 Comments