100 prisoners problem

Last updated
Each prisoner has to find their own number in one of 100 drawers, but may open only 50 of the drawers. 100 prisoners problem qtl1.svg
Each prisoner has to find their own number in one of 100 drawers, but may open only 50 of the drawers.

The 100 prisoners problem is a mathematical problem in probability theory and combinatorics. In this problem, 100 numbered prisoners must find their own numbers in one of 100 drawers in order to survive. The rules state that each prisoner may open only 50 drawers and cannot communicate with other prisoners. At first glance, the situation appears hopeless, but a clever strategy offers the prisoners a realistic chance of survival.

Contents

Anna Gál and Peter Bro Miltersen first proposed the problem in 2003.

Problem

The 100 prisoners problem has different renditions in the literature. The following version is by Philippe Flajolet and Robert Sedgewick: [1]

The director of a prison offers 100 death row prisoners, who are numbered from 1 to 100, a last chance. A room contains a cupboard with 100 drawers. The director randomly puts one prisoner's number in each closed drawer. The prisoners enter the room, one after another. Each prisoner may open and look into 50 drawers in any order. The drawers are closed again afterwards. If, during this search, every prisoner finds their number in one of the drawers, all prisoners are pardoned. If even one prisoner does not find their number, all prisoners die. Before the first prisoner enters the room, the prisoners may discuss strategy — but may not communicate once the first prisoner enters to look in the drawers. What is the prisoners' best strategy?

If every prisoner selects 50 drawers independently and randomly, the probability that a single prisoner finds their number is 50%. The probability that all prisoners find their numbers is the product of the single probabilities, which is (1/2)1000.0000000000000000000000000000008, a vanishingly small number. The situation appears hopeless.

Solution

Strategy

Surprisingly, there is a strategy that provides a survival probability of more than 30%. The key to success is that the prisoners do not have to decide beforehand which drawers to open. Each prisoner can use the information gained from the contents of every drawer they already opened to decide which one to open next. Another important observation is that this way the success of one prisoner is not independent of the success of the other prisoners, because they all depend on the way the numbers are distributed. [2]

To describe the strategy, not only the prisoners, but also the drawers, are numbered from 1 to 100; for example, row by row starting with the top left drawer. The strategy is now as follows: [3]

  1. Each prisoner first opens the drawer labeled with their own number.
  2. If this drawer contains their number, they are done and were successful.
  3. Otherwise, the drawer contains the number of another prisoner, and they next open the drawer labeled with this number.
  4. The prisoner repeats steps 2 and 3 until they find their own number, or fail because the number is not found in the first fifty opened drawers.

If the prisoner could continue indefinitely this way, they would inevitably loop back to the drawer they started with, forming a permutation cycle (see below). By starting with their own number, the prisoner guarantees they are on the specific cycle of drawers containing their number. The only question is whether any cycle is longer than fifty drawers - and only one cycle can possibly be too long, since at most one can comprise more than half of the total drawers.

Examples

The reason this is a promising strategy is illustrated with the following example using 8 prisoners and drawers, whereby each prisoner may open 4 drawers. The prison director has distributed the prisoners' numbers into the drawers in the following fashion:

number of drawer 1    2    3    4    5    6    7    8  
number of prisoner74681352

The prisoners now act as follows:

In this case, all prisoners find their numbers. This is, however, not always the case. For example, the small change to the numbers of swapping drawers 5 and 8 would cause prisoner 1 to fail after opening 1, 7, 5, and 2 (and not finding their own number):

number of drawer  1    2    3    4    5    6    7    8  
number of prisoner74682351

And in the following arrangement, prisoner 1 opens drawers 1, 3, 7, and 4, at which point they have to stop unsuccessfully:

number of drawer  1    2    3    4    5    6    7    8  
number of prisoner31758642

Indeed, all prisoners except 6 (who succeeds directly) fail.

Permutation representation

Permutation cycles qtl1.svg
Permutation cycles qtl2.svg
Graph representations of the permutations (1 7 5)(2 4 8)(3 6) and (1 3 7 4 5 8 2)(6)

The prison director's assignment of prisoner numbers to drawers can mathematically be described as a permutation of the numbers 1 to 100. Such a permutation is a one-to-one mapping of the set of natural numbers from 1 to 100 to itself. A sequence of numbers which after repeated application of the permutation returns to the first number is called a cycle of the permutation. Every permutation can be decomposed into disjoint cycles, that is, cycles which have no common elements. The permutation of the first example above can be written in cycle notation as

and thus consists of two cycles of length 3 and one cycle of length 2. The permutation of the third example is accordingly

and consists of a cycle of length 7 and a cycle of length 1. The cycle notation is not unique since a cycle of length can be written in different ways depending on the starting number of the cycle. During the opening the drawers in the above strategy, each prisoner follows a single cycle which always ends with their own number. In the case of eight prisoners, this cycle-following strategy is successful if and only if the length of the longest cycle of the permutation is at most 4. If a permutation contains a cycle of length 5 or more, all prisoners whose numbers lie in such a cycle do not reach their own number after four steps.

Probability of success

Probability distribution of the length of the longest cycle of a random permutation of the numbers 1 to 100. The green area corresponds to the survival probability of the prisoners. Permutation longest cycle length pmf qtl2.svg
Probability distribution of the length of the longest cycle of a random permutation of the numbers 1 to 100. The green area corresponds to the survival probability of the prisoners.

In the initial problem, the 100 prisoners are successful if the longest cycle of the permutation has a length of at most 50. Their survival probability is therefore equal to the probability that a random permutation of the numbers 1 to 100 contains no cycle of length greater than 50. This probability is determined in the following.

A permutation of the numbers 1 to 100 can contain at most one cycle of length . There are exactly ways to select the numbers of such a cycle (see combination). Within this cycle, these numbers can be arranged in ways since there are permutations to represent distinct cycles of length because of cyclic symmetry. The remaining numbers can be arranged in ways. Therefore, the number of permutations of the numbers 1 to 100 with a cycle of length is equal to

The probability, that a (uniformly distributed) random permutation contains no cycle of length greater than 50 is calculated with the formula for single events and the formula for complementary events thus given by

where is the -th harmonic number. Therefore, using the cycle-following strategy the prisoners survive in a surprising 31% of cases. [3]

Asymptotics

The harmonic numbers are approximately given by the area under the hyperbola and can therefore be approximated by a logarithm. Integral Test.svg
The harmonic numbers are approximately given by the area under the hyperbola and can therefore be approximated by a logarithm.

If instead of 100 prisoners are considered, where an arbitrary natural number, the prisoners' survival probability with the cycle-following strategy is given by

With the Euler–Mascheroni constant , for

holds, which results in an asymptotic survival probability of

Since the sequence of probabilities is monotonically decreasing, the prisoners survive with the cycle-following strategy in more than 30% of cases independently of the number of prisoners. [3]

Optimality

In 2006, Eugene Curtin and Max Warshauer gave a proof for the optimality of the cycle-following strategy. The proof is based on an equivalence to a related problem in which all prisoners are allowed to be present in the room and observe the opening of the drawers. Mathematically, this equivalence is based on Foata's transition lemma, a one-to-one correspondence of the (canonical) cycle notation and the one-line notation of permutations. In the second problem, the survival probability is independent of the chosen strategy and equal to the survival probability in the original problem with the cycle-following strategy. Since an arbitrary strategy for the original problem can also be applied to the second problem, but cannot attain a higher survival probability there, the cycle-following strategy has to be optimal. [2]

History

The 100 prisoners problem was first considered in 2003 by Anna Gál and Peter Bro Miltersen in the proceedings of the 30. International Colloquium on Automata, Languages and Programming (ICALP). [4] In their version, player A (the prison director) randomly colors strips of paper with the names of the players of team B (the prisoners) in red or blue and puts each strip into a different box. Some of the boxes may be empty (see below). Every player of team B must guess their color correctly after opening half of the boxes for their team to win. [4] Initially, Gál and Miltersen assumed that the winning probability quickly tends to zero with increasing number of players. However, Sven Skyum, a colleague at Aarhus University, brought his attention to the cycle-following strategy for the case of this problem where there are no empty boxes. To find this strategy was left open as an exercise in the publication. The paper was honored with the best paper award. [2]

In spring 2004, the problem appeared in Joe Buhler and Elwyn Berlekamp's puzzle column of the quarterly The Emissary of the Mathematical Sciences Research Institute. Thereby, the authors replaced boxes by ROMs and colored strips of paper by signed numbers. The authors noted that the winning probability can be increased also in the case where the team members don't find their own numbers. If the given answer is the product of all the signs found and if the length of the longest cycle is half the (even) number of players plus one, then the team members in this cycle either all guess wrong or all guess right. Even if this extension of the strategy offers a visible improvement for a small number of players, it becomes negligible when the number of players becomes large. [5]

In the following years, the problem entered the mathematical literature, where it was shaped in further different ways, for example with cards on a table [6] or wallets in lockers (locker puzzle). [2] In the form of a prisoner problem it was posed in 2006 by Christoph Pöppe in the journal Spektrum der Wissenschaft and by Peter Winkler in the College Mathematics Journal . [7] [8] With slight alterations this form was adopted by Philippe Flajolet, Robert Sedgewick and Richard P. Stanley in their textbooks on combinatorics. [1] [3]

Variants

Empty boxes

At first, Gál and Miltersen considered in their paper the case that the number of boxes is twice the number of team members while half of the boxes are empty. This is a more difficult problem since empty boxes lead nowhere and thus the cycle-following strategy cannot be applied. It is an open problem whether in this case the winning probability tends to zero with growing number of team members. [4]

In 2005, Navin Goyal and Michael Saks developed a strategy for team B based on the cycle-following strategy for a more general problem in which the fraction of empty boxes as well as the fraction of boxes each team member is allowed to open are variable. The winning probability still tends to zero in this case, but slower than suggested by Gál and Miltersen. If the number of team members and the fraction of boxes which are opened is fixed, the winning probability stays strictly larger than zero when more empty boxes are added. [9]

David Avis and Anne Broadbent considered in 2009 a quantum theoretical variant in which team B wins with certainty. [10]

The malicious director

In case the prison director does not have to distribute the numbers into the drawers randomly, and realizes that the prisoners may apply the above-mentioned strategy and guesses the box numbering the prisoners will apply (such as numbers indicated on the boxes), they can foil the strategy. To this end, they just have to ensure that their assignment of prisoners' numbers to drawers constitutes a permutation with a cycle of length larger than 50. The prisoners in turn can counter this by agreeing among themselves on a specific random numbering of the drawers, provided that the director does not overhear this or does not bother to respond by replacing numbers in the boxes before the prisoners are let in. [11]

One prisoner may make one change

In the case that one prisoner may enter the room first, inspect all boxes, and then switch the contents of two boxes, all prisoners will survive. This is so since any cycle of length larger than 50 can be broken, so that it can be guaranteed that all cycles are of length at most 50.

Any prisoner who finds their number is free

In the variant where any prisoner who finds their number is free, the expected probability of an individual's survival given a random permutation is as follows:

Without strategy:

With the strategy for the original problem:

It is noteworthy that although we receive the same expected values, they are from very different distributions. With the second strategy, some prisoners are simply destined to die or live given a particular permutation, and with the first strategy (i.e., no strategy), there is "truly" a 1/2 chance for every permutation.

Monty Hall problem

In 2009, Adam S. Landsberg proposed the following simpler variant of the 100 prisoners problem which is based on the well-known Monty Hall problem: [12]

Behind three closed doors a car, the car keys and a goat are randomly distributed. There are two players: the first player has to find the car, the second player the keys to the car. Only if both players are successful they may drive the car home. The first player enters the room and may consecutively open two of the three doors. If they are successful, the doors are closed again and the second player enters the room. The second player may also open two of the three doors, but they cannot communicate with the first player in any form. What is the winning probability if both players act optimally?

If the players select their doors randomly, the winning probability is only 4/9 (about 44%). The optimal strategy is, however, as follows:

In the six possible distributions of car, keys and goat behind the three doors, the players open the following doors (in the green cases, the player was successful):

Car − Keys − GoatCar − Goat − KeysKeys − Car − GoatKeys − Goat − CarGoat − Car − KeysGoat − Keys − Car
Player 1Door 1: CarDoor 1: CarDoor 1: Keys
Door 2: Car
Door 1: Keys
Door 2: Goat
Door 1: Goat
Door 3: Keys
Door 1: Goat
Door 3: Car
Player 2Door 2: KeysDoor 2: Goat
Door 3: Keys
Door 2: Car
Door 1: Keys
(Door 2: Goat)
(Door 3: Car)
(Door 2: Car)
(Door 1: Goat)
Door 2: Keys

The success of the strategy is based on building a correlation between the successes and failures of the two players. Here, the winning probability is 2/3, which is optimal since the first player cannot have a higher winning probability than that. [12] In a further variant, three prizes are hidden behind the three doors and three players have to independently find their assigned prizes with two tries. In this case the winning probability is also 2/3 when the optimal strategy is employed. [13]

Odd number of tries

Instead of having to find their number within the first 50 tries, the test could be finding the number within the 50 odd-numbered tries, 1, 3, ..., 97, 99. Any individual prisoner has a 50% chance of finding their own number on an odd-numbered try. The main strategy will work for all the prisoners if the permutation of the prisoners contains only cycles of odd length. For 100 prisoners the probability that all will succeed using the main strategy is approximately 7.9589%, which is substantially better than the probability (1/2)100 that would be obtained if each prisoner opened drawers independently at random.

See also

Related Research Articles

<span class="texhtml mvar" style="font-style:italic;">e</span> (mathematical constant) Constant value used in mathematics

The number e is a mathematical constant approximately equal to 2.71828 that can be characterized in many ways. It is the base of the natural logarithm function. It is the limit of as n tends to infinity, an expression that arises in the computation of compound interest. It is the value at 1 of the (natural) exponential function, commonly denoted It is also the sum of the infinite series

<span class="mw-page-title-main">Pigeonhole principle</span> If there are more items than boxes holding them, one box must contain at least two items

In mathematics, the pigeonhole principle states that if n items are put into m containers, with n > m, then at least one container must contain more than one item. For example, of three gloves, at least two must be right-handed or at least two must be left-handed, because there are three objects but only two categories of handedness to put them into. This seemingly obvious statement, a type of counting argument, can be used to demonstrate possibly unexpected results. For example, given that the population of London is more than one unit greater than the maximum number of hairs that can be on a human's head, the principle requires that there must be at least two people in London who have the same number of hairs on their heads.

<span class="mw-page-title-main">Birthday problem</span> Probability of shared birthdays

In probability theory, the birthday problem asks for the probability that, in a set of n randomly chosen people, at least two will share a birthday. The birthday paradox refers to the counterintuitive fact that only 23 people are needed for that probability to exceed 50%.

In mathematics, the harmonic series is the infinite series formed by summing all positive unit fractions:

<span class="mw-page-title-main">Maxwell–Boltzmann statistics</span> Statistical distribution used in many-particle mechanics

In statistical mechanics, Maxwell–Boltzmann statistics describes the distribution of classical material particles over various energy states in thermal equilibrium. It is applicable when the temperature is high enough or the particle density is low enough to render quantum effects negligible.

In mathematics, the probabilistic method is a nonconstructive method, primarily used in combinatorics and pioneered by Paul Erdős, for proving the existence of a prescribed kind of mathematical object. It works by showing that if one randomly chooses objects from a specified class, the probability that the result is of the prescribed kind is strictly greater than zero. Although the proof uses probability, the final conclusion is determined for certain, without any possible error.

In combinatorial mathematics, the Bell numbers count the possible partitions of a set. These numbers have been studied by mathematicians since the 19th century, and their roots go back to medieval Japan. In an example of Stigler's law of eponymy, they are named after Eric Temple Bell, who wrote about them in the 1930s.

In combinatorics, the symbolic method is a technique for counting combinatorial objects. It uses the internal structure of the objects to derive formulas for their generating functions. The method is mostly associated with Philippe Flajolet and is detailed in Part A of his book with Robert Sedgewick, Analytic Combinatorics, while the rest of the book explains how to use complex analysis in order to get asymptotic and probabilistic results on the corresponding generating functions.

In combinatorics, Bertrand's ballot problem is the question: "In an election where candidate A receives p votes and candidate B receives q votes with p > q, what is the probability that A will be strictly ahead of B throughout the count?" The answer is

<span class="mw-page-title-main">Continuous uniform distribution</span> Uniform distribution on an interval

In probability theory and statistics, the continuous uniform distributions or rectangular distributions are a family of symmetric probability distributions. Such a distribution describes an experiment where there is an arbitrary outcome that lies between certain bounds. The bounds are defined by the parameters, and which are the minimum and maximum values. The interval can either be closed or open. Therefore, the distribution is often abbreviated where stands for uniform distribution. The difference between the bounds defines the interval length; all intervals of the same length on the distribution's support are equally probable. It is the maximum entropy probability distribution for a random variable under no constraint other than that it is contained in the distribution's support.

<span class="mw-page-title-main">Secretary problem</span> Mathematical problem involving optimal stopping theory

The secretary problem demonstrates a scenario involving optimal stopping theory that is studied extensively in the fields of applied probability, statistics, and decision theory. It is also known as the marriage problem, the sultan's dowry problem, the fussy suitor problem, the googol game, and the best choice problem. Its solution is also known as the 37% rule.

In mathematics, especially in combinatorics, Stirling numbers of the first kind arise in the study of permutations. In particular, the Stirling numbers of the first kind count permutations according to their number of cycles.

In combinatorial mathematics, the rencontres numbers are a triangular array of integers that enumerate permutations of the set { 1, ..., n } with specified numbers of fixed points: in other words, partial derangements. For n ≥ 0 and 0 ≤ k ≤ n, the rencontres number Dnk is the number of permutations of { 1, ..., n } that have exactly k fixed points.

The statistics of random permutations, such as the cycle structure of a random permutation are of fundamental importance in the analysis of algorithms, especially of sorting algorithms, which operate on random permutations. Suppose, for example, that we are using quickselect to select a random element of a random permutation. Quickselect will perform a partial sort on the array, as it partitions the array according to the pivot. Hence a permutation will be less disordered after quickselect has been performed. The amount of disorder that remains may be analysed with generating functions. These generating functions depend in a fundamental way on the generating functions of random permutation statistics. Hence it is of vital importance to compute these generating functions.

<span class="mw-page-title-main">Monty Hall problem</span> Probability puzzle

The Monty Hall problem is a brain teaser, in the form of a probability puzzle, based nominally on the American television game show Let's Make a Deal and named after its original host, Monty Hall. The problem was originally posed in a letter by Steve Selvin to the American Statistician in 1975. It became famous as a question from reader Craig F. Whitaker's letter quoted in Marilyn vos Savant's "Ask Marilyn" column in Parade magazine in 1990:

Suppose you're on a game show, and you're given the choice of three doors: Behind one door is a car; behind the others, goats. You pick a door, say No. 1, and the host, who knows what's behind the doors, opens another door, say No. 3, which has a goat. He then says to you, "Do you want to pick door No. 2?" Is it to your advantage to switch your choice?

Bertrand's box paradox is a veridical paradox in elementary probability theory. It was first posed by Joseph Bertrand in his 1889 work Calcul des Probabilités.

In mathematics, the Golomb–Dickman constant arises in the theory of random permutations and in number theory. Its value is

<span class="mw-page-title-main">Fisher–Yates shuffle</span> Algorithm for generating a random permutation of a finite set

The Fisher–Yates shuffle is an algorithm for shuffling a finite sequence. The algorithm takes a list of all the elements of the sequence, and continually determines the next element in the shuffled sequence by randomly drawing an element from the list until no elements remain. The algorithm produces an unbiased permutation: every permutation is equally likely. The modern version of the algorithm takes time proportional to the number of items being shuffled and shuffles them in place.

The randomized weighted majority algorithm is an algorithm in machine learning theory for aggregating expert predictions to a series of decision problems. It is a simple and effective method based on weighted voting which improves on the mistake bound of the deterministic weighted majority algorithm. In fact, in the limit, its prediction rate can be arbitrarily close to that of the best-predicting expert.

In combinatorial mathematics, the hook length formula is a formula for the number of standard Young tableaux whose shape is a given Young diagram. It has applications in diverse areas such as representation theory, probability, and algorithm analysis; for example, the problem of longest increasing subsequences. A related formula gives the number of semi-standard Young tableaux, which is a specialization of a Schur polynomial.

References

  1. 1 2 Philippe Flajolet, Robert Sedgewick (2009), Analytic Combinatorics, Cambridge University Press, p. 124
  2. 1 2 3 4 Eugene Curtin, Max Warshauer (2006), "The locker puzzle", Mathematical Intelligencer, 28: 28–31, doi:10.1007/BF02986999, S2CID   123089718
  3. 1 2 3 4 Richard P. Stanley (2013), Algebraic Combinatorics: Walks, Trees, Tableaux, and More, Springer, pp. 187–189
  4. 1 2 3 Anna Gál, Peter Bro Miltersen (2003), "The cell probe complexity of succinct data structures", Proceedings 30th International Colloquium on Automata, Languages and Programming (ICALP), pp. 332–344
  5. Joe Buhler, Elwyn Berlekamp (2004), "Puzzles Column", The Emissary, Spring 2004: 3
  6. Richard E. Blahut (2014), Cryptography and Secure Communication, Cambridge University Press, pp. 29–30
  7. Christoph Pöppe (2006), "Mathematische Unterhaltungen: Freiheit für die Kombinatoriker", Spektrum der Wissenschaft (in German), 6/2006: 106–108
  8. Peter Winkler (2006), "Names in Boxes Puzzle", College Mathematics Journal, 37 (4): 260, 285, 289
  9. Navin Goyal, Michael Saks (2005), "A parallel search game", Random Structures & Algorithms, 27 (2): 227–234, doi:10.1002/rsa.20068, S2CID   90893
  10. David Avis, Anne Broadbent (2009), "The quantum locker puzzle", Third International Conference on Quantum, Nano and Micro Technologies ICQNM '09, pp. 63–66
  11. Philippe Flajolet, Robert Sedgewick (2009), Analytic Combinatorics, Cambridge University Press, p. 177
  12. 1 2 Adam S. Landsberg (2009), "The Return of Monty Hall", Mathematical Intelligencer, 31 (2): 1, doi: 10.1007/s00283-008-9016-8
  13. Eric Grundwald (2010), "Re: The Locker Puzzle", Mathematical Intelligencer, 32 (2): 1, doi: 10.1007/s00283-009-9107-1

Literature