The Monty Hall problem is a

probability brain teaser

based on the classic game show, Try playing the game a few times,

alternating between the stay and switch strategy

. Look at your win percentages for both strategies. Notice anything interesting?Choose a door!

Stay Wins: 0

Stay Losses: 0

Stay Win %: NaN%

Switch Wins: 0

Switch Losses: 0

Switch Win %: NaN%

Total Wins: 0

Total Losses: 0

Total Win %: NaN%

Surprisingly, the

odds of winning the car aren’t 50-50

. Let’s walk through the following scenario together to understand why. Click on the nodes to follow along!

1. Suppose you choose Door 1.

Since there are 3 doors, each has an equal 1/3 probability of containing the car. 2. Location of the car.

If the car is behind Door 1, Monty will open either Door 2 or Door 3 with an equal 1/2 probability since neither holds the car. If the car is behind Door 2, Monty will open Door 3 so as not to reveal the car. If the car is behind Door 3, Monty will open Door 2 so as not to reveal the car.3. Understanding path probability.

To get the probability of a path, multiply the probabilities on that path. For example, suppose you follow the top path, i.e. you pick Door 1, the car is actually behind Door 1, Monty opens Door 2, and you decide to stay. The probability of this path is $\frac{1}{3}(\frac{1}{2}) = \frac{1}{6}$ .4. Finally, let’s analyze each strategy.

(Make sure you’ve expanded all nodes first!)Looking at all of the Stay paths, see how the total path probabilities leading to the Car and Goat differ.

Car: $\frac{1}{3}(\frac{1}{2}) + \frac{1}{3}(\frac{1}{2}) = \frac{1}{3}$

Goat: $\frac{1}{3}(1) + \frac{1}{3}(1) = \frac{2}{3}$

Now do the same for all of the Switch paths.

Car: $\frac{1}{3}(1) + \frac{1}{3}(1) = \frac{2}{3}$

Goat: $\frac{1}{3}(\frac{1}{2}) + \frac{1}{3}(\frac{1}{2}) = \frac{1}{3}$

As you can see,

switching doubles your chances

of winning the car!
You may be thinking that once there are only 2 doors left, the odds of winning must be 50-50. These choices would be equally likely if you knew nothing about either choice, but the key is that you do. Monty knows where the car is and won’t choose to open the door with the car. Thus, by revealing a door with a goat, he’s giving you more information. You’re left with

a more informed choice rather than a random one

, making the probability of that last door having the car greater than a random 50-50.
If you only played the game a few times, you may not see that staying gives you a 1/3 chance and switching gives you a 2/3 chance of winning. However, as you increase the number of trials, you will see that the win percentages do, indeed, **converge to 33.3% if you **

switch

See for yourself by running the similulation below!

Note that running a single trial includes one trial of the stay strategy and one trial of the switch strategy.Understandably, you may still be skeptical about why switching doors can double your chances of winning. Let’s go through a larger scenario to see why switching is always in your favor. Imagine that instead of 3 doors, there are 100 doors. There is still only 1 prize, but this time, Monty opens 98 doors.

In other words, you originally pick 1 door, which has a 1/100 chance of containing the car. Monty looks at the 99 other doors and opens 98 with goats. In essence, he is

filtering the other doors and leaving you with the best door out of the 99

. So now, do stick with your random original door, or the door that was filtered out from 99 other doors? Hopefully you can see that

a filtered choice is better than a random one

. Now let’s see how much switching helps you, depending on the scenario.As described, the problem can be generalized to any number of doors and prizes.

Suppose there are $d$ doors, $p$ prizes, and Monty opens $x$ doors

. Because Monty will never open the door you originally chose or open a door with a prize behind it, the number of doors he will open is constrained to $x \leq d-1-p$ Since there are $d$ doors and $p$ prizes, the

probability that your initial choice will contain a prize

is $p_i = \frac{p}{d}$ Considering the summation of all $d$ doors, the

probability of winning

is $\frac{p}{d} \times d = p$ As Monty opens doors without prizes, this sum $p$ must remain the same, since

all of the probability of winning remains in the unopened doors

. As explained, the original door you select has a probability $p_i$ of winning. The $d-1-x$ remaining doors must all have the same probability $p_r$ . Thus, this sum must be $p_i + p_r(d-1-x) = p$ Rearranging the equation (click here to show/hide all of the steps), the

probability of winning for one of the remaining doors $p_r$

is $p_r = p_i \times \frac{d-1}{d-1-x}$

Thus, if you switch doors, you will have a $p_r$ probability of winning, which is

always greater than your original $p_i$ probability

since $\frac{d-1}{d-1-x} \geq 0$ for all values of $x$ and $d$ . Note that $d \geq x$ since $x \leq d-1-p$ as previously described.

This value also represents the

benefit of switching

, i.e. the factor by which switching increases your chance of winning. For the traditional Monty Hall problem, this factor is $\frac{3-1}{3-1-1} = 2$ and $p_i$ and $p_r$ are $1/3$ and $2/3$ , respectively.

Input values for the number of doors $d$ , the number of prizes $p$ , and the number of doors Monty will open $x$ .

See how the benefit of switching changes as you vary these values, then play the game!

$d$ :

$p$ :

$x$ :

$p_i$ ):

0.3333

$p_r$ ):

0.6667

2.00

Choose a door!

Stay Wins: 0 Stay Losses: 0

Stay Win %: NaN%

Switch Wins: 0 Switch Losses: 0

Switch Win %: NaN%

Total Wins: 0 Total Losses: 0

Total Win %: NaN%