Tag Archives: bayes

Car or Goat? The Monty Hall problem

 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? (Whitaker, 1990, as quoted by vos Savant 1990a)

Remember the awesome scene in the movie “21” starred by Kevin Spacey about him (Professor Rosa) asking Ben (Jim Sturgess) exactly the same question mentioned above?

Were you (as me!) among the ones who at the end of the scene kept staring the screen wondering “what the hell is going on here?”?

Well, if so take a look at the following post!

The above brain teaser is known among mathematicians and statisticians as the so called Monty Hall problem , named after the original host (Monty Hall) of an American TV game show who first mentioned the trick.

In the recalled “21” movie scene Ben answers Prof Rosa’s question claiming that changing door is indeed in his favor because the probability of getting a car after the host has opened a fake door switches from the 33,3% (1/3) of the beginning to the 66,6% (2/3). Is it true?

If you don’t want to get too much insights into the mathematical description you may be satisfied with the following image showing in a qualitative way the reasoning behind Ben’s answer. The player has an equal chance (1/3) of initially selecting the car, goat A or goat B. Suppose the car was behind door 1; then if he selects it, the host could open door 2 or 3 but in any case switching would turn into a lose for the player (switching loses = 1/3). If  instead the player selected door 2, then the host could only open door 3, meaning that switching would turn into a win for our player. The same would happen if the candidate selected door 3; in this case too he would win if he decided to change to the left door. This qualitative analysis shows that in two cases out of three changing own’s mind wins, resulting in a global probability of 2/3 = 66,6% against 1/3 = 33,3% of winning in case of switching door.


Now let’s turn into something a bit more sophisticated. Same problem, same solution, different but more rigorous path to get there.

We are going to tackle the teaser applying the Bayes Theorem about conditional probability which states that “the probability of event A given B is equal to the probability of event A and B divided by the probability of event B alone”. In order to fully understand what goes on behind the scenes let’s summarize the problem by the decision tree shown below.


The diagram has been built assuming the player would choose always door 1 as his primary decision and the upcoming discussion may be as well followed sticking to the image below which is a self explanatory figure of the above tree. The probability the car is hiding behind one of the three doors is exactly 1/3. We shall begin with the first top branch. Given that the car stays behind door 1 the host may decide to open door 2 or 3 with the same probability of 1/2 (remember that the player selected door 1 behind which there is the car, meaning the other two doors hide goats). The probability the host opens door 2 or 3 given the car is hiding behind door 1 and the player has selected door 1 is (1/3 x 1/2) = 1/6.

Now let’s move to the second branch. If the car stays behind door 2 and the player has selected door 1 then the host can open only door 3 with a probability of 1. This means that the  the probability the host opens door 3 given the car is hiding behind door 2 and the player has selected door 1 is (1/3 x 1) = 1/3.

The same reasoning holds for the third branch resulting in the fact that the probability the host opens door 2 given the car is hiding behind door 3 and the player has selected door 1 is (1/3 x 1) = 1/3.

Now let’s apply Bayes Theorem which states that $$P(A|B)=\frac{P(A \; AND \; B)}{P(B)}$$

In our case:

  • A = the player wins by switching from door 1 to door 2 which is the same as the car is behind door 2.
  • B = the host opens door 3.

Summarizing, we’re answering the following question “What is the probability the player wins switching door given his first choice was door 1 and the host opens door 3?“. Note that the result wouldn’t change if I asked the same question conditioning the probability with the host opening door 2. Which translated into Bayes notation is

$$ P(car \, is \, behind \, door \, 2 \, | \, host \, opens \, door \, 3)=\frac{P(car \, is \, behind \, door \, 2 \, AND\, host \, opens \, door \, 3)}{P(host \, opens \, door \, 3)} $$

computing the probabilities helping us with the previous decision tree we have:

  • P(car is behind door 2  AND host opens door 3) = 1/3
  • P(host opens door 3) = 1/6 + 1/3 = 1/2

$$ P(car \, is \, behind \, door \, 2 \, | \, host \, opens \, door \, 3)= \frac{\frac{1}{3}}{\frac{1}{2}} = \frac{2}{3} = 66,6\%$$

Here we are! Finally quod erat demonstrandum! 


That’s it! Cool, isn’t it?


by Francesco Pochetti