A Fun Application of the Probabilistic Method


2025-04-14 Update Part 2: I have been able to improve the constant to 3log2n/log2(27/23)12.973 \log_2 n / \log_2 (27/23) \approx 12.97 from the previous  15.57 ~15.57 .

2025-04-14 Update: There was an error in my previous writeup. It has been fixed in the version below. Kyle also shared with me that this problem is an example of non-adaptive group testing, a well-studied subject. I also improved the constant from 4log2n/log2(8/7)20.76 4\log_2 n / \log_2(8/7) \approx 20.76 to 3log2n/log2(8/7)15.57 3\log_2 n / \log_2(8/7) \approx 15.57 , by improving the second union bound

Background

After sharing with Kyle (my advisor) that I had looked at a few leetcode questions for fun, he mentioned he always loved going to interview during the end of his Ph.D. because they had fun questions. He shared with me the following:

Poisoned Bottle Problem

Suppose there are n n bottles, 1 of which is poisoned. You have to do a single round of testing to find out which bottle is poisoned. That is, you must send l l people to go test various bottles. Each person can drink from as many bottles as you wish, and if they drink from the poisoned bottle, no matter how little, they will die in 10 minutes.

The question is: what is the minimal number l l of testers required to locate the poisoned bottle?

The answer is: l=log2n l = \lceil \log_2 n \rceil . It is done as follows: put the bottles in order, and number them sequentially: 0,1,2, 0, 1, 2, \ldots . Now, for person k, k, k=1,2,,log2n k = 1, 2, \ldots, \lceil \log_2 n \rceil , they will drink from bottle l l if it contains a 1 1 in the k k -th digit of its binary expansion.

Then, each subset of people who die corresponds exactly to which bottle was poisoned. If, say, person 1 and 3 die, then you know that bottle number 1012=5 101_2 = 5 was poisoned.

Notice that this solution is optimal. That is, you would need a surjective map from {0,1}l{1,2,,n} \{0,1\}^l \to \{1, 2, \ldots, n\} . That is, 2ln 2^l \geq n , so that llog2(n) l \geq \log_2 (n) .

d d -Poisoned Bottle Problem

The above problem was pretty straightforward. Here’s a fun extension: suppose that 2 2 of the bottles are poisoned (or more generally, d d bottles). What is the minimal number of people required to detect which bottle was poisoned?

It wasn’t immediately obvious how to tackle this problem. At first, I thought about breaking the group down iteratively into groups of 3, using 2 people to test each block:

text

But this doesn’t work for the problem, as you would have to subsequently test all 3 blocks (because you have to do only a single round of testing).

Then, tinkering around at the board for a second, I realized that a random configuration should work well. With this thought, I moved forward with the probabilistic method.

Probabilistic Method

Recall that the probabilistic method comes from the following situation. You want to find out that an object X X with property Y Y exists. If you can pick a random such object and show that

P(X has property Y)>0, \mathbb{P}(X \text{ has property } Y) > 0,

then you know such an X X exists. So to this end, let ξi{0,1}n \xi_i \in \{0,1\}^n be (random) testers. That is, ξi \xi_i drinks from bottle j j if (ξi)j=1 (\xi_i)_{j=1} . Then we have that

P((ξi,i=1,2,,l) can detect every pair of bottles)\mathbb{P}((\xi_i, i = 1, 2, \ldots, l) \text{ can detect every pair of bottles})

=1P( a poisoned pair s.t. (ξi) cannot correctly detect)= 1 - \mathbb{P}(\exists \text{ a poisoned pair s.t. } (\xi_i) \text{ cannot correctly detect})

1(n2)P((ξi) cannot detect when (1,2) is the poisoned pair).\geq 1 - \binom{n}{2}\mathbb{P}((\xi_i) \text{ cannot detect when } (1,2) \text{ is the poisoned pair} ).

However, we can think of (ξi) (\xi_i) detecting the poisoned pair as being able to correctly conclude that every pair (i,j)(1,2) (i,j) \neq (1,2) is not the poisoned pair. Notice that for any (i,j)(1,2) (i,j) \neq (1,2) , we may assume by a union bound that i=3 i = 3 .

P((ξi) cannot detect when (1,2) is the poisoned pair).\mathbb{P}((\xi_i) \text{ cannot detect when } (1,2) \text{ is the poisoned pair} ).

nP(1,2)((ξi) cannot declare that (3,j) is not poisoned)\leq n \mathbb{P}_{(1,2)}((\xi_i) \text{ cannot declare that } (3,j) \text{ is not poisoned} )

Notice that if there exists a tester which tests bottle 3 3 , but not bottles 1 1 or 2 2 , this tester will live, and we can conclude that the poisoned pair does not contain a 3. Therefore, we have:

P(1,2)((ξi) cannot declare that (3,j) is not poisoned)\mathbb{P}_{(1,2)} ((\xi_i) \text{ cannot declare that } (3,j) \text{ is not poisoned} )

P(1,2)(i,(ξi)3(0,0,1))=(2327)l,\mathbb{P}_{(1,2)} (\forall i, (\xi_i)|_3 \neq (0,0,1)) = \left(\frac{23}{27}\right)^{l},

where we now choose the ξi \xi_i to be Bernoulli(1/3) (1/3) , in order to minimize the probability being exponentiated by l l .

Putting this all together, we have:

P((ξi,i=1,2,,l) can detect every pair of bottles)\mathbb{P}((\xi_i, i = 1, 2, \ldots, l) \text{ can detect every pair of bottles})

1n3(2327)l>0\geq 1 - n^3 \left( \frac{23}{27} \right)^l > 0

whenever l>3log2nlog227/23 l > \frac{3 \log_2 n}{\log_2 27/23} . This solution is optimal up to the 3/log227/23 3 / \log_2 27/23 , as there needs to be a unique mapping from every pair of bottles to the subsets of {1,2,,l} \{ 1, 2, \ldots, l\} . That is, (n2)2l \binom{n}{2} \leq 2^{l} , so that llog2(n2)2log2n l \geq \log_2 \binom{n}{2} \sim 2 \log_2 n .

Algorithms

While this result doesn’t give you a deterministic algorithm, it does imply, for instance, that if you take 13log2n 13\log_2 n random testers, you expect with high probability (1o(1)) (1 - o(1)) that you will be able to deduce any pair of poisoned bottles. While you can use the above method to get a result for any d d which is logarithmic in n n , we don’t necessarily expect this solution to be optimal in asymptotics in d d , given the information-theoretic lower bound.

Conclusion

This was a fun use of the probabilistic method to determine an upper bound on how many testers you need to solve the 2 2 -poisoned bottle problem. A similar approach can be used to get a bound for the d d -poisoned bottle problem.