I thought I would highlight an interesting brain teaser today. It comes in the form of a probability puzzle and is loosely based on the American television game show *Let’s Make a Deal. *The problem is known as the Monty Hall Problem.

The problem is as follows:

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?

Seeing this problem for the first time one might presume there is no advantage to switching your choice. But the answer might surprise you as it seems counterintuitive at first. However, it has been shown that there is in fact a distinct advantage to switching your choice and that the strategy that one should always employ is to switch your choice. The analysis of the Monty Hall problem requires a little bit of knowledge of probability but it isn’t difficult to understand.

I managed to find the following video On the Monty Hall Problem by the folks at Numberphile to be quite explanatory on the subject. It provides a good synopsis of the problem and gives an in depth understanding to the crux of the problem. I have embedded it below and highly suggest watching it as it gives a better explanation of the math and a proof of why the switching strategy works better than I could ever give it in this space.

If you want to read about the problem further this page on the Monty Hall problem has a thorough explanation of the problem and Steve Selvin has a rigorous mathematical explanation in terms of probability.

As you can see from watching the video or reading the links provided above if you stay with your initial choice you will always only have 1/3 probability of winning the car. However, as the video and links show mathematically it is to your advantage to switch your choice because it leads to a 2/3 probability of winning the car. Thus, the optimal solution or strategy is to always switch your choice because in the long run it leads to a higher probability of winning the car.

A simple simulation of the Monty Hall problem can be carried out with a program to verify that indeed the same mathematical results hold true when the Monty Hall problem is simulated many times. Below is a program written in Java that simulates the Monty Hall problem 100,000 times.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
import java.util.Random; public class Monty{ public static void main(String[] args){ int switchWins = 0; int stayWins = 0; Random gen = new Random(); for(int plays = 0;plays < 100000;plays++ ){ int[] doors = {0,0,0};//0 is a goat, 1 is a car doors[gen.nextInt(3)] = 1;//put a winner in a random door int choice = gen.nextInt(3); //pick a door, any door int shown; //the shown door do{ shown = gen.nextInt(3); //don't show the winner or the choice }while(doors[shown] == 1 || shown == choice); stayWins += doors[choice];//if you won by staying, count it //the switched (last remaining) door is (3 - choice - shown), because 0+1+2=3 switchWins += doors[3 - choice - shown]; } System.out.println("Switching wins " + switchWins + " times."); System.out.println("Staying wins " + stayWins + " times."); } } |

When you run this program the results should indicate that switching is the preferred outcome and alternative. When I ran this java program on my computer the simulation showed that switching wins 66,443 times and that staying wins 33,357 times. Thus, out of the 100,000 times the simulation was run you can see that the switching strategy won roughly 2/3 of the time and the staying strategy only won 1/3 of the time. As you can see this was in accordance with what was expected and in line with the math shown in the Numberphile video embedded above.