Guess Which Door Has A Car Behind It
There are three doors. Behind one of the doors is a car, and behind the other two are goats. Can you beat the odds, guess the correct door and win the car?
This problem is popularly known as the Monty Hall problem - named after the TV show host who ran Let’s Make a Deal back in the 60s and 70s. It goes like this: Monty asks you to pick a door. Let’s say you pick Door 1. Then Monty goes behind each door and sees where the car is, and where the goats are. He then proceeds to open, let’s say, Door 3 and reveals a goat. Monty now offers you a choice - do you want to STAY with Door 1, or do you want to SWITCH to Door 2.
Think about this for a second. And think in terms of probability - not in terms of I’m feeling lucky about Door 1 or Door 2 etc. What would you do?
I came across this problem when I went into a rabbit hole after watching a YouTube clip of Kevin Spacey (playing a professor) quizzing his class about this exact problem.
Here was my thinking: Now that Door 3 is eliminated, it’s a 50/50 toss up between Door 1 and Door 2. So it does not really matter if I stay or switch. I have no statistical advantage in doing either. In fact, I think I was lucky in not picking Door 3, and that I should let my lucky run continue and not mess things up - so I am going to STAY with Door 1. Turns out, this is flawed thinking! And it’s not just me, some really good mathematicians also argued that the odds are 50/50 between Door 1 and Door 2.
But first, I want you to try this for yourself. Below is a simulation of the Monty Hall problem. I want you to play this with two different strategies. First, I want you to play the STAY strategy. With this, you will pick a door, and when the goat is revealed, you will STAY with the same door you first picked. Playing this is easy, just keep clicking on the same door - again and again. At the end of the game, click anywhere to restart. To truly see the statistics play out, you need to play this at least 30 times. Next I want you to play the SWITCH strategy. For this, you will pick any door, and when the goat is revealed, you will SWITCH to the other remaining door. Again, play this about 30 times. Please indulge me, you need to see this for yourself to believe it:
Pick a door.
Win | Lose | Win % | |
---|---|---|---|
Stay | 0 | 0 | 0% |
Switch | 0 | 0 | 0% |
If you played this a lot of times, like 30 times for each strategy, you will most likely see about a 33% win rate for the STAY strategy, and about a 67% win rate for the SWITCH strategy. Shouldn’t it be 50/50 between the two strategies? What is happening?
To get our heads around this problem, let’s remove “you” from the equation and replace “you” with “Alice”. Alice is the player and she will be the one choosing the doors. For every choice Alice makes, there is the choice she did not make - the philosophical “road not taken” - let’s personify this as Bob. Let’s say that Bob is also a player, and he does NOT get to pick a door - he simply gets the doors that Alice does not pick.
So, if Alice picks Door 1, then Bob gets Door 2 and Door 3. At this point, Alice has a 33% probability of winning a car, and Bob has a 67% probability.
So, initially, when Alice picks Door 1, the probability of her winning is 33% and the probability of Bob (with Door 2 and Door 3) winning is 67%. Let’s call this STAGE 1. Then a goat is revealed in Door 3, and Alice is offered a choice to STAY with Door 1 or SWITCH to Door 2, let’s call that STAGE 2. Note that between STAGE 1 and STAGE 2, Monty did not SHUFFLE the car and goat behind Door 1 and Door 2. During the entire game, once the car is placed behind a Door - it does not move. As long as there is no SHUFFLING, then Bob’s odds of 67% does not change either.
But why doesn’t Bob’s probability go down from 67% to 50%? Because no new information has been revealed that changes that fact. There is still only ONE car, and there are three doors. Bob has 2 doors (doesn’t matter if it’s open or closed). So Bob’s probability stays at 67%. When Monty reveals the goat in Door 3, he is playing a trick. He is telling the audience, “Look! Bob has a goat behind one of his doors” - which really should surprise no one. Bob either has a car and a goat, or two goats. Saying “Bob has one goat” does not in any way change Bob’s odds of winning. The fact that Door 3 has a goat has strengthened Bob’s odds of having a car behind Door 2 - because keep in mind, Door 2 + Door 3 is 67%. So if Door 3 is a bust, then all that 67% probability goes to Door 2.
In other words, asking Alice if she wants to SWITCH to Door 2 is the same as asking if she wants to trade places with Bob, and his 67% probability of winning a car. If we put it that way, then we see that it makes sense to SWITCH.
Lastly, I want to go back to your original intuition of thinking the choice is 50/50 because there are only two doors left. That is true ONLY IF there is SHUFFLING of car and goat after STAGE 1. If there is SHUFFLING, then all bets are off. At that point, it does not make any statistical difference if you STAY or SWITCH.
Note that if you are playing the SWITCH strategy, you may still lose - that is why the odds are 67% and not 100%. No such thing as a free car, eh?
Hey, if you’ve made it this far, I have two favors to ask of you:
If you are a programmer, please go ahead and use your Github account to add reactions or comments below.
If you liked this post, please share this with others!
References
Note to programmers: When I was working on this simulation game, I wanted to make sure it was fair. Which means, if you play the game 30 times, irrespective of whether you win or not, the car should be behind Door 1 approximately 10 times, and behind Door 2 approximately ten times, and behind Door 3 approximately ten times. That is what you would expect in a pure random distribution. When I used Math.random()
I found that the results were wildly skewed. So, for my game I switched to crypto.getRandomValue()
. But that is not perfect either - because computers don’t really do random - they only do pseudorandom. Even then, my implementation has an “unfairness” to it. Read the function getRandomIndex()
in my source code, and tell me in comments below if you can spot what is unfair about it!