Monty Hall Problem

Another well known problem in probability is the Monty Hall problem.

You are presented with three doors (door 1, door 2, door 3). one door has a million dollars behind it. the other two have goats behind them. You do not know ahead of time what is behind any of the doors.

Monty asks you to choose a door. You pick one of the doors and announce it. Monty then counters by showing you one of the doors with a goat behind it and asks you if you would like to keep the door you chose, or switch to the other unknown door.

Should you switch? If so, why? What is the probability if you don’t switch? What is the probability if you do.

Lots of people have heard this problem.. so just knowing what to do isn’t sufficient. its the explanation that counts!

Solution

another well known problem in probability is the monty hall problem.

you are presented with three doors (door 1, door 2, door 3). one door has a million dollars behind it. the other two have goats behind them. you do not know ahead of time what is behind any of the doors.

monty asks you to choose a door. you pick one of the doors and announce it. monty then counters by showing you one of the doors with a goat behind it and asks you if you would like to keep the door you chose, or switch to the other unknown door.

should you switch? if so, why? what is the probability if you don’t switch? what is the probability if you do.

lots of people have heard this problem.. so just knowing what to do isn’t sufficient. its the explanation that counts!

the answer is that yes, you should *always* switch as switching increases your chances from 1/3 to 2/3. how so, you ask? well, lets just enumerate the possibilities.

           door 1       door 2       door 3
case 1 $$ goat goat
case 2 goat $$ goat
case 3 goat goat $$

its clear that if you just choose a door and stick with that door your chances are 1/3.

using the switching strategy, let’s say you pick door 1. if its case 1, then you lose. if it’s case 2, monty shows you door 3, and you switch to door 2, you win. if it’s case 3, monty shows you door 2, and you switch to door 3, you win. it doesn’t matter what door you pick in the beginning, there are always still three possibilities. one will cause you to lose, and two will cause you to win. so your chances of winning are 2/3.

the solution all resides in the fact that monty knows what is behind all the doors and therefore always eliminates a door for you, thereby increasing your odds.

maybe its easier to see in this problem. there are 1000 doors, only one of which has a prize behind it. you pick a door, then monty opens 998 doors with goats behind them. do you switch? it seems more obvious in this case, because monty had to take care in which door not to open, and in the process basically showing you where the prize was (999 out of 1000 times).

💡Strategies for Solving This Problem

Famous Probability Puzzle with Code

Got this at Dropbox in 2022. It's a classic probability problem that tests your ability to simulate and verify counter-intuitive results. Most people get the probability wrong initially.

The Problem

You're on a game show with 3 doors. Behind one door is a car, behind the other two are goats. You pick a door, say #1. The host, who knows what's behind the doors, opens another door (say #3) which has a goat. He asks: "Do you want to switch to door #2?"

Should you switch?

Intuitive Answer (Wrong)

Most people think it doesn't matter - 50/50 chance either way. Only 2 doors left, car is behind one of them, so 1/2 probability.

I thought this too at first. Interviewer smiled and said "Run a simulation."

The Math

Initially, you have 1/3 chance of picking the car. That means 2/3 chance the car is behind one of the other doors.

When the host opens a door with a goat, that 2/3 probability doesn't vanish - it transfers to the remaining door.

Your Choice Door #1 Door #2 Door #3 Host Opens Stay Wins? Switch Wins?
Door #1 Car Goat Goat #2 or #3 ✓ ✗
Door #1 Goat Car Goat #3 ✗ ✓
Door #1 Goat Goat Car #2 ✗ ✓

Stay wins: 1/3 of the time
Switch wins: 2/3 of the time

You should always switch!

Why It's Counter-Intuitive

The key is that the host's action gives you information. He's not opening a random door - he's always opening a door with a goat. This asymmetry changes the probabilities.

Simulation Approach

Run 10,000 simulations:

  1. Place car randomly behind one of 3 doors
  2. Player picks a door randomly
  3. Host opens a door (not player's choice, not the car)
  4. Calculate win rate for staying vs switching

At Dropbox

After I explained the wrong answer, interviewer had me code the simulation. When I ran it, I got ~33% for staying and ~67% for switching. He said "This is why we don't trust intuition in statistics - we write code to verify."

Scroll to Top