puzzle #20

Wide tables, equations, and code scroll sideways. Swipe, or Tab to focus them and use the left and right arrow keys.

Banach’s matchbox

You will learn: Derive the remaining-match law using the exact discovery stopping rule.

Start with: Events and probability

Two pockets each contain n matches. Whenever a match is needed, choose the left pocket with probability p and the right with probability 1 − p, independently of previous choices. Stop when the chosen pocket is already empty. How many matches remain in the other pocket?

The stopping sentence matters. Taking the last match from a pocket does not end this experiment. The empty pocket is discovered on a later attempt to take another. That distinction allows both pockets to be empty when discovery finally happens.

Reveal the attempts

Exact distribution of matches in the other pocket at discovery00.050.10.150246810matches left in other pocketprobability

Expected remaining matches: 2.700138. Probability both pockets are empty at discovery: 0.1761971.

Left: 9; right: 10. Attempt 1 chooses left: one match removed — continue even if that pocket is now empty.

Inspect revealed attempts and exact probabilities
AttemptPocketLeft afterRight afterDiscovery?
1Left910No
Remaining kExact P(K = k)
00.17619705
10.17619705
20.16692352
30.14837646
40.12219238
50.091644287
60.061096191
70.034912109
80.016113281
90.0053710938
100.00097656250
Each attempt independently chooses left with probability p. Stop on the first attempt to take from an already empty pocket. A seeded history illustrates this rule; the distribution is calculated analytically.

The chart is the exact distribution of the other pocket’s remaining count K. The seed controls one illustrative history. Reveal attempts one at a time and watch for the difference between removing a final match and making the failed attempt that ends the process. The final attempt changes neither remaining count.

The model permits a preference for one pocket, but that preference stays fixed. It does not learn which pocket is getting low, alternate sides deliberately, or choose only from nonempty pockets. Those policies would generate different stopping distributions.

Count histories ending on the left

Suppose discovery occurs on the left and the right has k matches. Before that last failed attempt, there have been n successful left choices and n − k successful right choices. Thus there are 2n − k successful attempts, followed by one more left choice.

The n left choices can occupy any n of those successful positions, giving the binomial coefficient C(2n − k, n). Every such order is allowed: neither pocket can have been selected while empty earlier, since the successful prefix contains at most its initial supply of choices from each side.

Each order, including the final failure, has probability p to the power n + 1, times (1 − p) to the power n − k. Reverse the pocket roles to obtain the other way discovery can occur. Therefore, for k from zero through n,

P(K = k) = C(2n − k, n) [p^(n+1)(1−p)^(n−k) + (1−p)^(n+1)p^(n−k)].

At p = 1/2 the two terms are equal, simplifying the expression to C(2n − k, n) / 2^(2n−k). Even at k = 0 the two final failed attempts are distinct outcomes, so adding them is appropriate. The formula’s probabilities sum to one.

Check the smallest nontrivial case

Start with one match in each pocket and choose fairly. After the first successful attempt, choosing that same pocket again discovers it empty while one match remains elsewhere. This happens with probability one half. Choosing the other pocket instead empties both, and the next attempt necessarily discovers an empty pocket. Thus K is zero or one with equal probability.

If we instead stopped the instant a pocket’s last match was removed, K would always be one in this example. The two questions have different answers despite using the same sequence of pocket choices. A stopping convention is part of the probability model, not an implementation detail.

The number of successful attempts at discovery is exactly 2n − K. Including the failed attempt makes the total 2n − K + 1. This identity provides another way to check any displayed history, and connects expected remaining matches to expected time until discovery.

Make a prediction

What happens when every attempt chooses the left pocket?

Explore the answer

For positive n, the first n attempts remove the left matches and attempt n + 1 discovers the empty left pocket. All n right matches remain. When n is zero, both pockets start empty and the very first attempt discovers this; K is zero.

The Random Services treatment derives the fair and biased-pocket laws through negative-binomial waiting times. Continue to the negative binomial distribution to compare a fixed number of successes with this competition between two supplies.

Reset all settings