The Monty Hall Problem

One car and some goats behind closed doors. Pick a door, let the host open others, and decide whether to switch. The page works out the chance behind every door from the host's rule and what he did, plays thousands of games to check it, or lets you play yourself. The table below shows the arithmetic.

Bayes' rule, the host's move as evidence P(Ci∣H)=P(H∣Ci) P(Ci)βˆ‘jP(H∣Cj) P(Cj)P(C_i\mid H)=\frac{P(H\mid C_i)\,P(C_i)}{\sum_j P(H\mid C_j)\,P(C_j)}
The host who knows and opens k goat doors at random P(Cd0∣H)=1nP(Cd∣H)=nβˆ’1n (nβˆ’1βˆ’k)\begin{aligned}P(C_{d_0}\mid H)&=\frac{1}{n}\\P(C_d\mid H)&=\frac{n-1}{n\,(n-1-k)}\end{aligned}
Loading interactive simulation...

Lesson

The theory β€” The Monty Hall Problem

The chance that the car is behind a given door, after the host has acted, follows from Bayes' rule: the prior for that door, 1 Γ· n, times the likelihood that the host would do exactly what he did if the car were there, divided by the total chance of what he did.

What each symbol means

n
the number of doors
k
the number of doors the host opens
P(H | C_i)
the likelihood: the chance the host does what he did if the car is behind door i
P(C_i | H)
the posterior: the chance the car is behind door i after seeing what the host did

Where the formula comes from

  1. Name the hypotheses and give each its prior. Ci is the car being behind door i; before the host acts, every door is equally likely.
    P(Ci)=1n,i=1,…,nP(C_i)=\frac{1}{n},\qquad i=1,\dots,n
  2. Write down how likely the host's move H is under each hypothesis. This is the only step where his rule enters. For the host who knows and opens k goat doors at random among the goat doors he may open, with your door d0 and the set O of doors he opened:
    P(H∣Cd0)=1(nβˆ’1k)P(H∣Cd)=1(nβˆ’2k),dβˆ‰OP(H∣Cd)=0,d∈O\begin{aligned}P(H\mid C_{d_0})&=\frac{1}{\binom{n-1}{k}}\\P(H\mid C_d)&=\frac{1}{\binom{n-2}{k}},\quad d\notin O\\P(H\mid C_d)&=0,\quad d\in O\end{aligned}
  3. Add up the total chance of what he did.
    P(H)=βˆ‘j=1nP(Cj) P(H∣Cj)P(H)=\sum_{j=1}^{n}P(C_j)\,P(H\mid C_j)
  4. Divide each prior times likelihood by that total. For the host who knows, your door keeps 1/n whichever doors he opens, and each of the m = n βˆ’ 1 βˆ’ k other closed doors gets (n βˆ’ 1)/(nm).
    P(Ci∣H)=P(Ci) P(H∣Ci)P(H)P(Cd0∣H)=1n,P(Cd∣H)=nβˆ’1n m\begin{aligned}P(C_i\mid H)&=\frac{P(C_i)\,P(H\mid C_i)}{P(H)}\\P(C_{d_0}\mid H)&=\frac{1}{n},\qquad P(C_d\mid H)=\frac{n-1}{n\,m}\end{aligned}

Problems solved in full

  1. The three doors, by Bayes' rule 4 steps

    You pick door 1. The host, who knows where the car is and always opens a goat door, choosing at random when he has a choice, opens door 3. Find the chance that the car is behind door 1 and behind door 2. Press Three doors to check.

    1/3 1/3 1/3 C₁ Cβ‚‚ C₃ 1/2 1/2 1 1 Hβ‚‚ H₃ H₃ Hβ‚‚ 1/6 1/6 1/3 1/3

    Open this problem in the tool

    1. Before he acts, each door is equally likely:

      P(C1)=P(C2)=P(C3)=13P(C_1)=P(C_2)=P(C_3)=\tfrac13
    2. How likely is it that he opens door 3, for each place the car could be?

      P(H3∣C1)=12,P(H3∣C2)=1,P(H3∣C3)=0P(H_3\mid C_1)=\tfrac12,\qquad P(H_3\mid C_2)=1,\qquad P(H_3\mid C_3)=0
    3. The total chance that he opens door 3:

      P(H3)=13β‹…12+13β‹…1+13β‹…0=12P(H_3)=\tfrac13\cdot\tfrac12+\tfrac13\cdot 1+\tfrac13\cdot 0=\tfrac12
    4. Divide each door's prior times likelihood by that total:

      P(C1∣H3)=13β‹…1212=13,P(C2∣H3)=13β‹…112=23P(C_1\mid H_3)=\dfrac{\tfrac13\cdot\tfrac12}{\tfrac12}=\tfrac13,\qquad P(C_2\mid H_3)=\dfrac{\tfrac13\cdot 1}{\tfrac12}=\tfrac23

    Answer

    The car is behind door 1 with probability 1/3 and behind door 2 with probability 2/3. The whole answer sits in the second step: if the car is behind door 2 he is forced to open door 3, and if it is behind door 1 he opens door 3 only half the time, so his opening door 3 is twice as likely if the car is behind door 2.

    P(C1∣H3)=13,P(C2∣H3)=23P(C_1\mid H_3)=\tfrac13,\qquad P(C_2\mid H_3)=\tfrac23
  2. Four doors, one opened 5 steps

    Four doors. You pick door 1, and the host, who knows where the car is, opens one of the other doors that hides a goat, choosing at random when he can. He opens door 4. Find the chance that the car is behind each closed door, then check it by counting before he acts.

    Open this problem in the tool

    Show solution
    1. Before he acts:

      P(C1)=P(C2)=P(C3)=P(C4)=14P(C_1)=P(C_2)=P(C_3)=P(C_4)=\tfrac14
    2. How likely is it that he opens door 4, for each place the car could be? With the car behind door 1 he has three goat doors to choose from; behind door 2 or door 3, only two:

      P(H4∣C1)=13P(H4∣C2)=P(H4∣C3)=12P(H4∣C4)=0\begin{aligned}&P(H_4\mid C_1)=\tfrac13\\&P(H_4\mid C_2)=P(H_4\mid C_3)=\tfrac12\\&P(H_4\mid C_4)=0\end{aligned}
    3. The total chance that he opens door 4:

      P(H4)=14(13+12+12)=13P(H_4)=\tfrac14\left(\tfrac13+\tfrac12+\tfrac12\right)=\tfrac13
    4. Divide each door's prior times likelihood by that total:

      P(C1∣H4)=14β‹…1313=14P(C2∣H4)=P(C3∣H4)=14β‹…1213=38\begin{aligned}&P(C_1\mid H_4)=\dfrac{\tfrac14\cdot\tfrac13}{\tfrac13}=\tfrac14\\&P(C_2\mid H_4)=P(C_3\mid H_4)=\dfrac{\tfrac14\cdot\tfrac12}{\tfrac13}=\tfrac38\end{aligned}
    5. The same figure without Bayes: switching to a closed door chosen at random wins only if the first pick was wrong, chance 3/4, and then the car is behind one of the two closed doors:

      34β‹…12=38\tfrac{3}{4}\cdot\tfrac{1}{2}=\tfrac{3}{8}

    Answer

    Door 1 keeps 1/4; doors 2 and 3 have 3/8 each. Switching beats staying, but the 3/4 that doors 2, 3 and 4 held between them is now shared by two doors, so neither of them reaches it.

    P(C1∣H4)=14,P(C2∣H4)=P(C3∣H4)=38P(C_1\mid H_4)=\tfrac14,\qquad P(C_2\mid H_4)=P(C_3\mid H_4)=\tfrac38
  3. A host who does not know 4 steps

    Three doors, and you pick door 1. This host does not know where the car is: he opens door 2 or door 3 at random, and door 3 happens to show a goat. Find the chance that the car is behind door 1 and behind door 2. Press Host who does not know to check.

    Open this problem in the tool

    Show solution
    1. Before he acts:

      P(C1)=P(C2)=P(C3)=13P(C_1)=P(C_2)=P(C_3)=\tfrac13
    2. Write H3 for door 3 opened with a goat behind it. With the car behind door 1 or door 2 he opens door 3 half the time and a goat is there. With the car behind door 3, opening it shows the car, so H3 cannot happen:

      P(H3∣C1)=12P(H3∣C2)=12P(H3∣C3)=0\begin{aligned}&P(H_3\mid C_1)=\tfrac12\\&P(H_3\mid C_2)=\tfrac12\\&P(H_3\mid C_3)=0\end{aligned}
    3. The total chance of H3:

      P(H3)=13β‹…12+13β‹…12+13β‹…0=13P(H_3)=\tfrac13\cdot\tfrac12+\tfrac13\cdot\tfrac12+\tfrac13\cdot 0=\tfrac13
    4. Divide:

      P(C1∣H3)=13β‹…1213=12P(C2∣H3)=13β‹…1213=12\begin{aligned}&P(C_1\mid H_3)=\dfrac{\tfrac13\cdot\tfrac12}{\tfrac13}=\tfrac12\\&P(C_2\mid H_3)=\dfrac{\tfrac13\cdot\tfrac12}{\tfrac13}=\tfrac12\end{aligned}

    Answer

    1/2 and 1/2. The opened door and the goat are the same as in the first problem. Only the likelihood for door 2 changed, from 1 to 1/2, because this host was never forced to avoid the car.

    P(C1∣H3)=P(C2∣H3)=12P(C_1\mid H_3)=P(C_2\mid H_3)=\tfrac12
  4. A host with a favourite door 5 steps

    Three doors, you pick door 1, and the host knows where the car is. When the car is behind door 1, so that he may open either door 2 or door 3, he opens door 2 with probability p. Find the chance that switching wins if he opens door 2, and if he opens door 3. Then take p = 1: the host who always opens the lowest-numbered goat door. Press Biased host opens 2 to check p = 1.

    Open this problem in the tool

    Show solution
    1. Before he acts:

      P(C1)=P(C2)=P(C3)=13P(C_1)=P(C_2)=P(C_3)=\tfrac13
    2. The likelihood of each move. With the car behind door 2 or door 3 he has no choice:

      P(H2∣C1)=p,P(H3∣C1)=1βˆ’pP(H2∣C2)=0,P(H3∣C2)=1P(H2∣C3)=1,P(H3∣C3)=0\begin{aligned}&P(H_2\mid C_1)=p,&&P(H_3\mid C_1)=1-p\\&P(H_2\mid C_2)=0,&&P(H_3\mid C_2)=1\\&P(H_2\mid C_3)=1,&&P(H_3\mid C_3)=0\end{aligned}
    3. The total chance of each move:

      P(H2)=13(1+p)P(H3)=13(2βˆ’p)\begin{aligned}&P(H_2)=\tfrac13(1+p)\\&P(H_3)=\tfrac13(2-p)\end{aligned}
    4. Divide. Switching after door 2 means taking door 3, and after door 3 it means taking door 2:

      P(C3∣H2)=13β‹…113(1+p)=11+pP(C2∣H3)=13β‹…113(2βˆ’p)=12βˆ’p\begin{aligned}&P(C_3\mid H_2)=\dfrac{\tfrac13\cdot 1}{\tfrac13(1+p)}=\dfrac{1}{1+p}\\&P(C_2\mid H_3)=\dfrac{\tfrac13\cdot 1}{\tfrac13(2-p)}=\dfrac{1}{2-p}\end{aligned}
    5. With p = 1:

      p=1:P(C3∣H2)=12,P(C2∣H3)=1p=1:\quad P(C_3\mid H_2)=\tfrac12,\quad P(C_2\mid H_3)=1

    Answer

    Switching wins with probability 1/(1 + p) after door 2 and 1/(2 βˆ’ p) after door 3. Both are at least 1/2 for every p from 0 to 1, so switching never does worse than staying, whatever his preference. With p = 1 they are 1/2 and 1; with p = 1/2, the host of the first problem, both are 2/3.

    11+pβ‰₯12,12βˆ’pβ‰₯12(0≀p≀1)\dfrac{1}{1+p}\ge\tfrac12,\qquad\dfrac{1}{2-p}\ge\tfrac12\qquad(0\le p\le1)
  5. When the offer is the evidence 5 steps

    Three doors, you pick door 1. When your pick is the car, the host always offers a switch; when it is a goat, he offers with probability q. Whenever he offers he opens a goat door, at random if there are two. He offers and opens door 3. For which q should you switch? Monty Hell is q = 0: press Monty Hell to check it.

    Open this problem in the tool

    Show solution
    1. Before he acts:

      P(C1)=P(C2)=P(C3)=13P(C_1)=P(C_2)=P(C_3)=\tfrac13
    2. H3 is now an offer with door 3 opened. With the car behind door 1 he offers for certain and opens door 3 half the time; behind door 2 he offers with probability q and has to open door 3; behind door 3 he cannot open it:

      P(H3∣C1)=1β‹…12P(H3∣C2)=qβ‹…1P(H3∣C3)=0\begin{aligned}&P(H_3\mid C_1)=1\cdot\tfrac12\\&P(H_3\mid C_2)=q\cdot 1\\&P(H_3\mid C_3)=0\end{aligned}
    3. The total chance of H3:

      P(H3)=13(12+q)P(H_3)=\tfrac13\left(\tfrac12+q\right)
    4. Divide:

      P(C1∣H3)=1212+q=11+2qP(C2∣H3)=q12+q=2q1+2q\begin{aligned}&P(C_1\mid H_3)=\dfrac{\tfrac12}{\tfrac12+q}=\dfrac{1}{1+2q}\\&P(C_2\mid H_3)=\dfrac{q}{\tfrac12+q}=\dfrac{2q}{1+2q}\end{aligned}
    5. Compare the two closed doors:

      2q1+2q>11+2qβ€…β€ŠβŸΊβ€…β€Šq>12q=1:Β 23q=0:Β 0\begin{aligned}&\dfrac{2q}{1+2q}>\dfrac{1}{1+2q}\iff q>\tfrac12\\&q=1:\ \tfrac23\\&q=0:\ 0\end{aligned}

    Answer

    Switch when q > 1/2 and stay when q < 1/2; at q = 1/2 they are equal. The host who always offers, q = 1, gives switching 2/3, and Monty Hell, q = 0, gives it nothing. The offer is evidence of its own: from a host who offers to a wrong pick less than half as often as to a right one, it says stay.

    P(C2∣H3)=2q1+2q>12β€…β€ŠβŸΊβ€…β€Šq>12P(C_2\mid H_3)=\dfrac{2q}{1+2q}>\tfrac12\iff q>\tfrac12
  6. Bertrand's boxes 4 steps

    Three boxes hold two gold coins, two silver coins, and one of each. You choose a box at random and take out one of its coins at random. It is gold. Find the chance that the other coin in that box is gold too.

    Show solution
    1. Call the boxes GG, SS and GS. Before the draw:

      P(GG)=P(SS)=P(GS)=13P(GG)=P(SS)=P(GS)=\tfrac13
    2. How likely is a gold coin from each box?

      P(G∣GG)=1P(G∣SS)=0P(G∣GS)=12\begin{aligned}&P(G\mid GG)=1\\&P(G\mid SS)=0\\&P(G\mid GS)=\tfrac12\end{aligned}
    3. The total chance of drawing gold:

      P(G)=13β‹…1+13β‹…0+13β‹…12=12P(G)=\tfrac13\cdot 1+\tfrac13\cdot 0+\tfrac13\cdot\tfrac12=\tfrac12
    4. Divide:

      P(GG∣G)=13β‹…112=23P(GG\mid G)=\dfrac{\tfrac13\cdot 1}{\tfrac12}=\tfrac23

    Answer

    2/3, not the 1/2 you get by counting the two boxes that could hold a gold coin. The gold box gives gold every time and the mixed box half the time, so a gold coin is twice as likely to have come from the first. Joseph Bertrand set the puzzle in his Calcul des probabilitΓ©s of 1889, 86 years before Steve Selvin put the three doors to readers of The American Statistician.

    P(GG∣G)=23P(GG\mid G)=\tfrac23

Supplementary problems, answers only

  1. Three prisoners, A, B and C, learn that one of them, chosen at random, will be pardoned. A asks the guard to name one of the other two who will be executed; if both will be, the guard names one at random. He names B. Find the chance that A is pardoned, and that C is.

    Show answer

    1/3 and 2/3. It is the three doors, with the guard as the host.

    13,23\tfrac13,\qquad\tfrac23
  2. A hundred doors. The host who knows opens 98 of the 99 doors you did not pick, all goats. Find the chance for your door and for the one he left shut.

    Show answer

    1/100 and 99/100.

    1100,99100\tfrac{1}{100},\qquad\tfrac{99}{100}
  3. Five doors. The host who knows opens two goat doors at random among the four you did not pick. Find the chance for your door and for each of the other two closed doors.

    Show answer

    1/5, and 2/5 each.

    15,25\tfrac15,\qquad\tfrac25
  4. Ten doors. A host who does not know opens 8 of the 9 doors you did not pick, at random, and all 8 hide goats. Find the chance for your door and for the other closed door, and the chance that such a host shows 8 goats at all.

    Show answer

    1/2 and 1/2; he shows 8 goats with probability 1/5.

    12,12;10βˆ’810=15\tfrac12,\qquad\tfrac12;\qquad\tfrac{10-8}{10}=\tfrac15
  5. In the problem of the host with a favourite door, take p = 1/3. He opens door 3. Find the chance that switching wins.

    Show answer

    1/(2 βˆ’ 1/3) = 3/5.

    12βˆ’13=35\dfrac{1}{2-\tfrac13}=\tfrac35
  6. A thousand games with the host who knows. Between which two rates should the switching win rate land 95% of the time?

    Show answer

    2/3 ± 1.96 √((2/3 · 1/3)/1000): from 63.74% to 69.59%.

    23Β±1.9623β‹…131000=[0.6374,Β 0.6959]\tfrac23\pm1.96\sqrt{\dfrac{\tfrac23\cdot\tfrac13}{1000}}=[0.6374,\ 0.6959]

Switching wins two times in three

Press Three doors. You pick door 1, and it has a one-in-three chance of the car. Nothing this host does can change that: he would open door 3 half the time with the car behind your door, and when he has a choice he chooses at random, so his move carries no news about door 1. He opens door 3 and shows a goat. The two-in-three chance that the car was behind door 2 or door 3 now sits entirely on door 2, so switching wins 2 times in 3. Press 100 doors and it is plain: you picked one door in a hundred, the host opens 98 of the rest with goats behind them, and the single door he leaves shut is the one to take, 99 times in 100. In 1990 Marilyn vos Savant gave the three-door answer in her Parade column and received thousands of letters telling her she was wrong, many signed by people with doctorates.

The same view gives a different answer if the host did not know

Press Host who does not know. You see exactly what you saw before: door 1 picked, door 3 open, a goat. But this host opened a door at random and happened to miss the car, and now staying and switching both win 1 time in 2. The chance depends on the rule that produced what you see, not only on what you see. A host who knows, must show a goat, and picks at random when he can tells you nothing about your own door; all the chance he removes from door 3 moves to door 2. A host who opened door 3 at random would have shown a goat there just as often with the car behind door 1 as behind door 2, so the goat favours neither.

Which door he opens can be the whole answer

Press Biased host opens 2. This host always opens the lowest-numbered goat door he can. Door 2 is what he would open whether the car is behind door 1 or door 3, so seeing it does not favour one over the other, and staying and switching are 1 in 2. Press Biased host opens 3: he passed over door 2, which he would only do if the car were behind it, so switching wins every time. Averaged over the games, a half two thirds of the time and a certainty one third of the time, switching still wins 2 times in 3. Monty Hell is the host who offers a switch only when you have already found the car, and given an offer, switching always loses.

Learning path

Choosing on what you have seen