Understanding the Monty Hall Problem

I was recently listening to a podcast that was recommended by a blogger on this site, and during one episode discussing big-O theory, the…

Understanding the Monty Hall Problem
“The Game Show Host Problem” from the movie 21 (2008). Photo: © 2008 Relativity Media

I was recently listening to a podcast that was recommended to me, and during one episode which discussed big-O theory, the Monty Hall problem was mentioned. The commentators talked a little about it, at which point they admitted to not ‘getting it’ and moved on. This motivated me to share my understanding of the problem because I think that as engineers we should be the ones who are able to grasp this concept and problems like it.

So here’s how I ‘got it’. It took some thinking, but in the end, it’s actually not too complicated.

In case you are unfamiliar with the problem, the Monty Hall problem is as follows:

  • You are presented with 3 doors. Behind only one is a prize.
  • You pick a door which you think the prize may be behind.
  • After you pick the door, a 3rd party (ie the gameshow host) opens up a door which does NOT have the prize.
  • You are then given the option to either stay with your initial guess or switch your guess to the door which the game show host did NOT open.
  • Which should you do? Switch or stay? Does it matter?

The initial intuition for most people is that once you are shown the door with no prize, the possibility is now 50–50 between the two remaining doors, so it doesn’t matter if you switch or not. But this is not the case. It is actually probabilistically in your best interest to switch to the other door. But let’s be good engineers and follow the scientific process with an initial hypothesis that you have a 50% chance of winning either way.

We have our hypothesis, so let’s experiment.

Code:

Output:

Another way you could do it which can give you a little more info is to randomly switch between staying and switching your doors:

Code:

Output:

Ok, our hypothesis is wrong. Looks like we should probably switch doors. Time to refine my hypothesis and this time rely on more than just naive intuition. (Maybe you saw some new intuition above: that the only way you get a stay_win is if you guessed right initially)

There are a few ways to look at the problem. First, let’s look at a split universe timeline:

  • You have 3 doors and a prize behind one of them. So, for your initial pick, what is the probability that you correctly choose where the prize is?
  • Let’s freeze time right here and do a little more analysis. There are 2 possibilities that just happened in your choice. So let’s split our universe.
  • Universe 1: You fell within the 33.3% chance and chose correctly. Now, the game show host can open either of the remain doors, as neither of them has a prize. Now you have ANOTHER CHOICE (another split!)
  • // → Universe 1.1 You stay with your initial pick. (Human factor, let’s say 50%)
  • // → // →You Win (100%)
  • // →Universe 1.2 You switch. (50%)
  • // → // →You Lose (100%)
  • Universe 2 You initially choose wrong, which happens 66.7% of the time. Now, the game show host can ONLY open the door without the prize behind it (leaving the other door with the prize) SPLIT Universe 2
  • Universe 2.1 You stay with your initial pick. (50%)
  • You Lose (100%)
  • Universe 2.2 You switch. (50%)
  • You Win(100%)

Analyzing mathematically: So what’s our problem statement? We want to know whether we win more if we switch or stay, right? So let’s calculate the probability of winning given that you stay with your initial door, and then the probability of winning given that you switch doors. Note that we are giving the person a random 50% chance that they choose to switch or stay with their original door.

P(win | stay) = [P(win) * P(stay | win)] / P(stay)P(win) = (Universe 1 && Universe 1.1) || (Universe 2 && Universe 2.2) = (1/3) * (1/2) + (2/3) * (1/2) = 1/2P(stay | win) = Out of wins possibilities only, what percentage of those did you stay for?
= (Universe 1 && Universe 1.1) / [(Universe 1 && Universre 1.1) || (Universe 2 && Universe 2.2)] = (1/3) * (1/2) / (1/2) = 1/3P(stay) = (Universe 1 && Universe 1.1) || (Universe 2 && Universe 2.1) = (1/3) * (1/2) + (2/3) * (1/2) = 1/2P(win | stay) = [1/2 * 1/3] / 1/2 = 1/3

You could also say “Out of the times that I stay, how many times did I win?” That would give you the same answer:

P(win | stay): all wins which lie within stay universesP(win | stay) = (Universe 1 && Universe 1.1) / [(Universe 1 && Universe 1.1) || (Universe 2 && Universe 2.2)] = (1/3) * (1/2) / [(1/3) * (1/2) + (2/3) * (1/2)] = (1/3) * (1/2) / (1/2) = 1/3P(win | stay) = 1/3

Now, let’s see the probability of winning given you switch. (While Baye’s doesn’t really buy us anything since we have a short timeline which describes everything for us, I’ll do it both ways for the sake of thoroughness).

P(win | switch) = [P(win) * P(switch | win)] / P(switch)P(win) = (Universe 1 && Universe 1.1) || (Universe 2 && Universe 2.2) = (1/3) * (1/2) + (2/3) * (1/2) = 1/2P(switch | win) = Out of wins possibilities only, what percentage of those did you switch for?
= (Universe 2 && Universe 2.2) / [(Universe 1 && Universre 1.1) || (Universe 2 && Universe 2.2)] = (2/3) * (1/2) / (1/2) = 2/3P(switch) = (Universe 1 && Universe 1.2) || (Universe 2 && Universe 2.2) = (1/3) * (1/2) + (2/3) * (1/2) = 1/2P(win | switch) = [1/2 * 2/3] / 1/2 = 2/3

Or, you could say:

From our mathematical analysis, we can see that you are twice as likely to win if you switch than if you stay. You will also win more (2/3 of the time) if you switch every time than if you randomly choose to switch or stay (in which case you win 1/2 of the time)

Analyzing with logic: If you choose to always switch, you will always be right if you initially chose the wrong door. So, since you initially choose wrong ( 1- 1/3 = ) 66.67% of the time, you will be guaranteed to choose the correct door 66.67% of the time if you always switch. If you choose never to switch, you are guaranteed to be correct only if you initially picked the correct door out of the 3 on your first try, which was a 33.3% chance.

Expanding this problem out to get a better intuition: Sometimes when a problem seems hard to grasp, I like to take the numbers to extremes while maintaining the necessary relationships. In this case, we know that after your choice of 1 door, the host will open all of the doors but one other (even though in our case with 3 doors, this is just him opening one door) AND these doors must have no prize. So, using this relationship, let’s expand our situation to 1 million doors with one prize. Now after you choose a door, the game show host has to open all the rest but one. And he can’t open the one with the prize. So, unless you think you chose right on your first try with a million to one odds, don’t you think this is a pretty good deal, as the host is practically forced to show you where the prize is?! This is the exact same concept, except now our odds for getting the prize when we switch are 999,999/1,000,000 instead of 2/3. It’s much easier to have intuition on this concept when it is expanded in this way.

Now, our hypothesis matches our experimental data, and we can call it a day.