This article aims to be a simple explanation of the Monty Hall problem. The Monty Hall problem is a famous thought experiment that when understood deepens our understanding of probability. Here is how it works. You are playing Let’s Make a Deal with Monty Hall. Let’s Make a Deal is a game in which there are 3 doors and behind one of the doors is a car and behind each of the two remaining doors is a goat. Your goal is to choose the door with the car. You choose a door. Monty Hall opens one of the remaining two doors that has a goat (at least one of the remaining doors always has a goat). Now two doors are open, and one remains closed. Monty Hall offers you a deal. His offer to you: do you want to change your choice to the remaining closed door?

**Question: **

Should you keep your first pick, or will you be better off changing your choice to the remaining closed door?

**Answer: **

You are better off by changing your first choice and taking Monty Hall’s offer.Your probability of winning changes from 1/3 to 2/3.

It is widely discussed that this answer is counter-intuitive. How can that be? I believe it helps to consider a slight variation of the question.

**Variation of Question: **

If you played the game 1,000 times with Monty Hall, would you be better off changing your choice to the remaining closed door each time?

Let’s start with a simple simulation of playing the game just 9 times. The table below shows 9 games in which your first choice is door 1 each time (column 2). In other words, you always choose door 1 in each of the games. We assume that the winning door with the car is randomly selected by the game show host and it is appears behind each door 3 times, that is 1/3 of the time (see column 3).

From the table below we can see that if you kept your first choice (door 1) each in each game and did not accept Monty Hall’s offer, the winning door 1 would occur 3 times, or 1/3 of the time (compare the matches between column 2 and column 3). The table shows the winning door (column 3) and the door with a the goat that is opened by Monty Hall (column 4). This means that the remaining door is closed (column 5). This closed door in column 5 represents Monty Hall’s offer to you to change your selection to this door. From the table below we see that if you changed your selection to accept Monty Hall’s offer each time, you will win 6 of 9 times, or 2/3 of the time (compare the matches between column 2 and column 5).

Game |
Your first choice door |
The winning door (with the car) |
The door with the goat opened by Monty Hall |
Monty Hall’s offer to change to this door |
If you don’t change |
If you change |

1 | 1 | 1 | 2 or 3 | 2 or 3 | Win | Lose |

2 | 1 | 1 | 2 or 3 | 2 or 3 | Win | Lose |

3 | 1 | 1 | 2 or 3 | 2 or 3 | Win | Lose |

4 | 1 | 2 | 3 | 2 | Lose | Win |

5 | 1 | 2 | 3 | 2 | Lose | Win |

6 | 1 | 2 | 3 | 2 | Lose | Win |

7 | 1 | 3 | 2 | 3 | Lose | Win |

8 | 1 | 3 | 2 | 3 | Lose | Win |

9 | 1 | 3 | 2 | 3 | Lose | Win |

Win 1/3 of the time | Win 2/3 of the time |

notes:

- Your first choice is always door 1.
- The door with the car is randomly selected and thus the car appears behind each of the doors 1/3 of the time.

**Simulating playing the game 1000 times**

In the first simulation, we assumed your first choice was always the same. Let’s change this scenario in two ways:

- You randomly chose your first door (ie you do not always chose the same door)
- You play the game 1,000 times

Below is some R code that simulates the Monty Hall problem for this scenario.

Let’ start with playing the game 10 times. After running the script that simulates playing the game 10 times the last line prints.

“If you change your door and play 10 times you’ll win0.6of the time.”

“If you keep your first choice and play 10 times you’ll win0.4of the time”

Ok 0.6 and 0.4 is not precisely 2/3 and 1/3. After running the script 3 times, I get.

- 0.8 and 0.2
- 0.6 and 0.4
- 0.7 and 0.3

We can see that due to a small sample (10), we don’t get the same answer every time. This is similar to the situation that if we flipped a coin 4 times which has a 50% chance of heads and a 50% chance of tails, it may not result in exactly 2 heads and 2 tails. Let’s increase the number of times playing the game from 10 to 1000. After running the script multiple times (ie playing the game 1000 times over and over), the program shows 0.66 and 0.33 nearly every time. By increasing it to 10,000 games, it is .66 and .33 always.

**It is better to change your first choice.**

If you played 1000 times, the evidence is clear that you are better off changing the door each.

**Monty Hall Simulation – R code**you can run this simulation at r-fiddle.org here http://www.r-fiddle.org/#/fiddle?id=IUHBtH27

` `

```
```numberofwins <- 0

numberofgames <- 1000

for (j in 1:numberofgames)

{

alldoors <- c(1, 2, 3)

doorwithcar <- sample(1:3, 1)

myfirstpick <- sample(1:3, 1)

reveal <- alldoors[which(alldoors != doorwithcar & alldoors != myfirstpick)]

revealed <- sample(c(reveal, reveal), 1)

cbind(doorwithcar, myfirstpick, revealed)

mysecondpick <- alldoors[which(alldoors != myfirstpick & alldoors != revealed)]

cbind(doorwithcar, myfirstpick, revealed, mysecondpick)

if (mysecondpick == doorwithcar)

{

numberofwins <- numberofwins + 1}

}

winrate_change <- round(sum(numberofwins * (1 / numberofgames)), digits = 3)

winrate_dontchange <- round(sum(1 - winrate_change), digits = 3)

print(c(paste("If you change your door and play", numberofgames, "times you will win", winrate_change, "of the time")))

print(c(paste("If you keep your first choice and play", numberofgames, "times you will win", winrate_dontchange, "of the time")))

` `