2

You know the riddle: https://sites.math.washington.edu/~morrow/336_11/papers/yisong.pdf

A 2nd version struck me the other day, using the exact same scenario & assumptions but with a different question to be answered: "Are you the last called prisoner out of the bunch?"

In other words: "Are you the 100th prisoner?"

Obviously, all prisoners called in the days 1-99 know they arent

Any thoughts? Is this "100 prisoners and a light bulb_v2" problem feasible?

1 Answers1

3

I just realized that the protocol below can be drastically improved by letting all prisonsers accumulate and pass on knowledge about the days on which prisoners were first called. Instead of just the prisoner first called on day $k+1$ leaving the light on on day $k$ of a run, any prisoner can do so who’s seen the light left on on such a day, and thus knows that someone was first called on day $k+1$. This makes it a lot more difficult to estimate the expected runtime, so I wrote some code that simulates this protocol. It also includes, as another improvement, that we start with $n=200$, $k=0$, so that many prisoners can immediately pass on their knowledge about their first day. The initial $n$ and the growth rate could certainly be further optimized. In this form, the expected runtime is about $800000$ days, or about $2200$ years; still beyond the reach of our mortal prisoners, but quite a significant improvement over the original idea below.


This will take ages, there may be much more efficient protocols, but the expected runtime is finite: Divide the days into growing runs of $n=1,2,3,\ldots$ days and number each day in the run with $k=1,\ldots,n$. In each run, a prisoner leaves the light on on the $k$-th day of the run if they were first called on the $(k+1)$-th day overall. The last prisoner called knows that she was the last to be called when she's seen the light left on on $98$ days with different numbers less than her own. (The prisoner called on the first day isn't involved since they're certain to have been first called on the first day.)

We can estimate the expected runtime as follows: First we have the standard coupon collector's runtime of $100H_{100}\approx519$ days until the last prisoner is called. Then, in every run except near the beginning there are $98$ eligible days on which the last prisoner may find the light on. Each of them is successful with probability $\frac1{100\cdot100}$, since a particular prisoner must be called on the previous day and then the last prisoner must be called. Thus, the last prisoner has a chance of $\frac1{10000}$ per eligible day to collect a coupon, and she needs to collect all $98$ different coupons.

Let $X$ be the number of coupons she needs to collect before she has all $98$, and $Y$ the number of eligible days this takes her. Then

$$ E[Y]=10000E[X]=10000\cdot98H_{98}\approx5.06\cdot10^6 $$

and, by the law of total variance,

\begin{eqnarray} \operatorname{Var}(Y) &=& E[\operatorname{Var}(Y\mid X)]+\operatorname{Var}(E[Y\mid X]) \\ &=& E\left[9999\cdot10000\cdot X\right]+\operatorname{Var}(10000\cdot X) \\ &=& 9999\cdot10000\cdot98H_{98}+10000^2\left(98^2H^{(2)}_{98}-98H_{98}\right) \\ &=& 10000^2\cdot98^2H^{(2)}_{98}-10000\cdot98H_{98} \\ &\approx& {1.57\cdot10^{12}}\;. \end{eqnarray}

(See Coupon collector's problem: mean and variance in number of coupons to be collected to complete a set (unequal probabilities) for the variance calculation). Thus

\begin{eqnarray} E\left[Y^2\right] &=& \operatorname{Var}(Y)+E[Y]^2 \\ &=& 10000^2\cdot98^2H^{(2)}_{98}-10000\cdot98H_{98}+\left(10000\cdot98H_{98}\right)^2 \\ &\approx& 2.72\cdot10^{13}\;. \end{eqnarray}

Since there are $98$ eligible days per run and $\frac12n(n+1)$ days in $n$ runs, the expected runtime of the protocol is approximately

\begin{eqnarray} E\left[\frac12\cdot\frac Y{98}\left(\frac Y{98}+1\right)\right] &=& \frac{E\left[Y^2\right]}{19208}+\frac{E[Y]}{196} \\ &\approx& 1.42\cdot10^9 \end{eqnarray}

days, or about $4$ million years. We could probably cut down on a large part of this by letting the runs grow more slowly, since we're using runs of length about $5\cdot10^4$ days even though we only expect to need about $5\cdot10^2$ of them. Still, that would get us at best to something like $100000$ years, well beyond the expected lifespan of the prisoners.

joriki
  • 238,052
  • +1. That this is possible at all is amazing enough, and you had a great analysis too! BTW can you imagine being one of the prisoners, and you have seen all the other numbers, but you still have to keep waiting for the last guy to see them too? :( – antkam Jan 07 '20 at 04:35
  • @antkam: Funny, just as you wrote that, I was editing the answer with a drastic improvement, which in that situation would allow you to pass on your knowledge instead of having to just wait :-). Unfortunately, it makes the analysis of the runtime a lot more difficult, so I simulated it instead. – joriki Jan 07 '20 at 04:38