Why Switch is Better than Stay in Monty Hall?

There are 3 doors A, B, and C. Behind one of these doors is a reward. You select door A. The host open door C and show that there is no reward in door C. Now, do you want to stay at door A or switch to door B? The answer is you need to always switch because it has more chance of wining. Find out why in python simulation!

Tisana Wanwarn
Geek Culture
6 min readSep 1, 2021

--

What is Monty Hall?

Monty Hall is a gameshow where there are 3 doors, behind 1 of the 3 doors contains a reward which is a car. First, you need to pick one of 3 doors. Then the host, who knows where the car is, will always open another door that you did not select and also do not contain the car. The host then ask “do you want to stay at the same door you have selected or do you want to switch to another door?”.

People normally think that choosing to stay or switch is a 50–50 percent chance. In fact it is not, always switching have more probability to win a car than staying at the same door you have selected.

Why is it so?

If there are 3 doors: 1, 2, and 3, behind one of these doors is a reward. If you select door 1. Then, the host open door 2 and show that there is no reward in door 2. Now the host ask, “DO you want to STAY or SWITCH?”

You might think that, the probability that the you will win the prize is 1/3. When door 2 is open by the host, you are left with 2 doors, then the probability of you wining a prize either stay at door 1 or switch to door 3 are the same which is 1/2.

Probability of wining and losing before the door is open (my screen shot)
Probability of wining and losing after the door is open (my screen shot)

If we think again. The probability that you will win is 1/3 at door 1. Also, the probability that you will not win which is the probability that the reward will be at the door you did not choose is 2/3 (at door 2 and door 3). However, once the host open door 2 and show that there is no reward here, it is not wrong at all to say that the probability that the reward will be at the door you did not choose, which is right now left with only door 3, is 2/3. This mean the probability that you will win a prize staying at door 1 is 1/3 while the probability that you will win a prize switching to door 3 is 2/3 which is higher.

If we increase the number of doors to even higher. Let say if there are 100 doors, namely 1,2,3,4,5 …. ,100. If you select door 1. Then the host open door 2 to door 99, you are now left with door 1 and door 100, “DO you want to STAY or SWITCH?”. If we use the same logic as before, the probability of wining staying at door 1 is 1/100 while the probability of wining switching to door 100 is 99/100. Now that seems to be a lot different between staying and switching. We will prove latter in the article that the probability of wining using switch strategy in 100 doors game is even higher than the probability of wining using switch strategy in 3 doors game. And also, the probability of wining using stay strategy in 100 doors game is even lower than the probability of wining using stay strategy in 3 doors game.

Python simulation

The python code below is to demonstrate what will happen if we have 2 types of players, the one who always “stay” and the one who always “switch”, playing the Monty Hall game for several times. Will any one of this player have significantly higher chance of wining than another?

Note: Every decision in every round of simulation is generated randomly bounded by some conditions, there is no fixing number here.

First, we need 2 input parameters. The num_trial, number of trial, is how many time the 2 players will play the game. The num_door, number of doors, is how many doors there will be in this game (originally there are only 3 doors, however more number of doors will be use in this simulation in order to support the theory mentioned above), but still the number of reward will still be fixed to 1 door regardless of the total number of doors.

Next, we create 2 functions, the function that randomly select which door the player will choose and the function that randomly assign which door will contain the car which is the reward. Actually we can use the same function since both of them are doing the same thing, but for the purpose of demonstration we separated them.

Next, the function open_door is for the host who will always open the door(s) that player did not select and also that should be the door that does not contain the reward. The function return the list of the name of the door that should be open (if we have 3 doors the host will be able to open only 1 door, if we have 4 doors the host need to open 2 doors). The while loop make sure that the door(s) to be opened should not be the door that the player select and also should not be the door that contains the reward. Other than that can be open.

Next, this is the switch function for the player who always switch. The switch function need to know what door the host have already open and also what door the player have selected at first in order to switch to the other door.

Finally, we have the function to check whether the player win the prize or not. If the player win the value is 1, if not 0.

Lets start simulation for 1000 trails. Each trial we record whether the player win or lose in the list for both “stay” strategy player and “switch” strategy player called stay_list and switch_list; receptively.

Then we cumulative sum the list and plot to compare.

The comparison of cumulative count of number of win between “stay” strategy player and “switch” strategy player for 1000 trails for 3 doors game (my screen shot)

Clearly the cumulative number of win for switch strategy player is higher than stay strategy player and the difference is increasing as the number of trial increase. This prove that always “SWITCH” have higher chance of wining.

Now let see if we have 100 doors in the game….

The comparison of cumulative count of number of win between “stay” strategy player and “switch” strategy player for 1000 trails for 3 doors and 100 doors game (my screen shot)

Clearly the cumulative number of win for switch strategy player for 100 doors game is even higher than switch strategy player for 3 doors game. Also, the cumulative number of win for stay strategy player for 100 doors game is even lower than stay strategy player for 3 doors game.

Full python code available here:

Summary

Switching have higher chance of wining in Monty Hall game. Also the difference between the cumulative number of win using switching strategy and cumulative number of win using stay strategy increases as the number of door increase.

--

--