Monty hall problem extended.

I just learned about the Monty Hall problem and found it quite amazing. So I thought about extending the problem a bit to understand more about it.

In this modification of the Monty Hall Problem, instead of three doors, we have four (or maybe $n$) doors, one with a car and the other three (or $n-1$) with a goat each (I want the car).

We need to choose any one of the doors. After we have chosen the door, Monty deliberately reveals one of the doors that has a goat and asks us if we wish to change our choice.

So should we switch the door we have chosen, or does it not matter if we switch or stay with our choice?

It would be even better if we knew the probability of winning upon switching given that Monty opens $k$ doors.

• As a side note, if you're trying to change the problem for the purpose of teaching it, (rather than just creating a fun variety,) you should have Monty reveal n-2 goats, where n=total doors at start. That still matches the original problem (he'd open 1 of the 3,) and it makes the correct answer (not switching) really obvious as N increases. "You pick 1 of 100 doors. He opens 98, revealing goats. Do you keep the one you picked, or switch to the other?" (See @Tony's answer below - I didn't before posting this, but it makes the same point. +1 to him.) Commented Dec 16, 2013 at 17:38
• OMG that is the perfect monty hall... I have a 3 in 4 chance of finally getting the goat my wife keeps telling me I cant have!
Commented Dec 16, 2013 at 23:01
• @Jaydles I don't know, people's intuitions are different. Two years ago, I saw that exact explanation, with a million doors rather than 100 (making it even more "obvious"). I still thought switching made no difference. Commented Dec 17, 2013 at 1:15
• A visual explanation: http://blog.vctr.me/monty-hall. Scroll down to the bottom to play with the strategy/doors/speed :) Commented Dec 17, 2013 at 3:16
• @einpoklum - The car is still the better outcome. If nothing else, it can be sold or traded for many goats... Enough to create a self-sustaining herd given sufficient suitable land. :) Commented Dec 17, 2013 at 12:01

I decided to make an answer out of my comment, just for the heck of it.

$n$ doors, $k$ revealed

Suppose we have $n$ doors, with a car behind $1$ of them. The probability of choosing the door with the car behind it on your first pick, is $\frac{1}{n}$.

Monty then opens $k$ doors, where $0\leq k\leq n-2$ (he has to leave your original door and at least one other door closed).

The probability of picking the car if you choose a different door, is the chance of not having picked the car in the first place, which is $\frac{n-1}{n}$, times the probability of picking it now, which is $\frac{1}{n-k-1}$. This gives us a total probability of $$\frac{n-1}{n}\cdot \frac{1}{n-k-1} = \frac{1}{n} \cdot \frac{n-1}{n-k-1} \geq \frac{1}{n}$$

No doors revealed
If Monty opens no doors, $k = 0$ and that reduces to $\frac{1}{n}$, which means your odds remain the same.

At least one door revealed
For all $k > 0$, $\frac{n-1}{n-k-1} > 1$ and so the probabilty of picking the car on your second guess is greater than $\frac{1}{n}$.

Maximum number of doors revealed
If $k$ is at its maximum value of $n-2$, the probability of picking a car after switching becomes $$\frac{1}{n}\cdot \frac{n-1}{n-(n-2)-1} = \frac{1}{n}\cdot \frac{n-1}{1} = \frac{n-1}{n}$$ For $n=3$, this is the solution to the original Monty Hall problem.

Switch.

• I like the added k, seems like the best answer so far (at least for me) Commented Dec 16, 2013 at 21:05
• If monty opens all doors except for one, then k will be n-2. Putting it in the general formula you made, the probability is $\frac{n-1}{n}$ . As n gets larger, the probability that we win increases. Infact, if number of doors is 40, a simulation on blog.vctr.me/monty-hall shows that we win 99 out of 100 times. Amazing! Commented Dec 17, 2013 at 14:00
• +1. The addition of $k$ makes this a really nice extension of the original problem. Commented Dec 18, 2013 at 11:10
• n-1/n solves for goats! Removing a door is ( n-1-1)/(n-1). 1 of the 1s is the car. So we have m = doors Monty removes. Solving for goats (getting the car by process of elimination) is ( n-1-m)/(n-m). The original odds are not 1 in 3. Eliminating a door leaves 1 in 2 for a goat or a car. Solving for a car by eliminating goats without a door removed are: 2/3 × 1/2 = 1/3, same as directly picking the car if a goat door is not removed. Commented Mar 13, 2022 at 18:17

By not switching, you win a car if and only if you chose correctly initially. This happens with probability $\frac{1}{4}$. If you switch, you win a car if and only if you chose incorrectly initially, and then of the remaining two doors, you choose correctly. This happens with probability $\frac{3}{4}\times\frac{1}{2}=\frac{3}{8}$. So if you choose to switch, you are more likely to win a car than if you do not switch.

You never told me whether you'd prefer to win a car or a goat though, so I can't tell you what to do.

• Credit to the origin of the picture xkcd.com/1282 Commented Dec 16, 2013 at 15:00
• I once lived out in the country, and it was a dream of mine to get two goats to keep the grass short. I wanted to name one of the goats Briggs, and the other one Stratton.
– J.R.
Commented Dec 17, 2013 at 10:49
• It's very similar to having a dog, just a little livelier. Commented Dec 17, 2013 at 14:02
• Goats are browsers; they'd prefer it if your yard was full of trees, bushes, brambles, and stuff they can reach up to. Although they'll graze if that's what's available they do better and stay healthier on browse. Commented Dec 17, 2013 at 19:12
• @mousomer: one of our funniest experiences was transporting a goat kid home in the back of a Subaru. Driving up I-77 we got a lot of really odd looks from people. (As one car passed us the woman in the passenger seat looked at us and I clearly saw her say, "What the f...?" :-). Don't think I ever laughed that much while driving, before or since - an' I swear, I was sober as a judge..! :-) Commented Dec 18, 2013 at 16:55

Let's reason in the case of $n$ windows and just $1$ car.

When Monty gives you the opportunity to modify your initial choice, it is definitely better to take it. Here's a way to see it:

The probability of finding the car with the first choice is just $\frac{1}{n}$, and this is the same probability that you have of winning if you keep your initial choice.

Of course you will win by changing your choice if the intersection of two events will happen:

1. You didn't choose the car with the first choice ( $P(A) = \frac{n-1}{n}$ )

2. You are lucky and you find the car with your second choice ( $P(B\mid A) = \frac{1}{n-2}$ )

So the probability of winning by changing your mind is the product $$P(A\cap B) = P(A)\cdot P( B\mid A ) = \frac{n-1}{n}\cdot \frac{1}{n-2} = \frac{n-1}{n(n-2)} > \frac{1}{n}$$ Since $\frac{n-1}{n-2} \to 1$ when $n\to \infty$, we notice that Monty's help is not that useful in the case of many many windows.

• We can generalize even further and have Monty opening $k$ doors (with $k <= n - 2$), for a probability of picking the right door on your second guess of $\frac{1}{n - k - 1}$.
– SQB
Commented Dec 16, 2013 at 19:19
• To add to this answer a little bit, consider the case with $n$ doors where Monty opens each of the remaining doors except for 1 (another, different generalization of the original problem to OP's). Then, again, if you don't switch your probability of winning is $\frac{1}{n}$, and if you do switch, your probability of winning is exactly equal to the probability that you chose incorrectly at first (this is identical to the case with 3 doors). Then your probability of winning is $\frac{n-1}{n}\rightarrow 1$ as $n\to\infty$, so in this case, Monty's help is incredibly useful.
– crf
Commented Dec 16, 2013 at 22:30
• "The above two events are independent" - no they are not. It is obvious that if you chose the car on your first pick, you will get a goat on your second. You need to rephrase this in terms of the conditional probability that you will choose right on your second choice, given that you chose wrong on your first. Commented Dec 16, 2013 at 23:15
• If monty opens only one door, the probability that we win with switching decreases with increase in number of doors. However, If monty opens all doors leaving behind 2 doors, the probability increases! Commented Dec 17, 2013 at 14:01
• @shauryagupta This is how I finally convinced my dad about this problem. I first said, we'll play the game with cards. I'll know where the ace is, and I'll ask you to pick and if you want to swap. We did about 6 times, but you don't reach convincing results fast enough. So I said, scrap that. We'll use the whole deck. You need to pick the ace of spades. After he picked one, I took the rest of the deck away except for one card. Then asked if he wanted to swap. It was pretty obvious at this point. Commented Dec 17, 2013 at 16:43

Increasing the number of doors is a common extension of the problem, and is analytically useful for giving people an intuition about why switching is optimal. This is not, strictly speaking, the situation you're describing (since your question is about adding a single door and Monty still only opening one door), but it's a similar case.

Consider a Monty Hall Problem of 100 doors: Let's say you choose one, then Monty opens 98 other doors. Which probability is higher: the probability that you picked the right one from the beginning (1%), or the probability that you didn't and thus the one door that Monty left unopened is the real winner (99%)?

Last time I came across a Monty Hall question I wrote my own tester in Java. Here it is - with the number of doors set to 4:

public class MontyHall {

// How many doors.
static final int Doors = 4;

// Prizes.
enum Prize {

Goat,
Car;
}

public static void main(String[] args) throws InterruptedException {
// The number of times we would have won if we switched.
int winWhenSwitched = 0;
// The number of times we would have won if we didn't switch.
int winWhenNotSwitched = 0;
// The number of times we would have lost both ways.
int lost = 0;

// n doors.
Prize doors[] = new Prize[Doors];
// N Tests
for (int i = 0; i < 100000; i++) {
// Put a car behind just one door.
pickRandomDoorForCar(doors);
// Make my first choice.
int firstChoice = randomDoor();
// Open one remaining goat door.
int goatDoorOpened = openOneGoatDoor(doors, firstChoice);
// What would have been my second choice - if I switched?
int secondChoice = makeSecondChoice(doors, firstChoice, goatDoorOpened);
// Count wins/losses.
if (doors[firstChoice] == Prize.Car) {
// We would have won without switching!
winWhenNotSwitched += 1;
} else {
// We win if we switched to the car!
if (doors[secondChoice] == Prize.Car) {
// We picked right!
winWhenSwitched += 1;
} else {
lost += 1;
}
}
}
System.out.println("Wins when switched = " + winWhenSwitched);
System.out.println("Wins when not switched = " + winWhenNotSwitched);
System.out.println("Lost = " + lost);
System.out.println("Proportion = " + ((double) winWhenSwitched / (double) winWhenNotSwitched));
}

// Open one door exposing a Goat.
private static int openOneGoatDoor(Prize doors[], int firstChoice) {
for (int j = 0; j < Doors; j++) {
// Not the one already picked and must contain goat.
if (j != firstChoice && doors[j] == Prize.Goat) {
// Can only be one of them.
return j;
}
}
// Should never get here - TODO - Throw an exception here.
return -1;
}

// Make a second choice - avoid first choice and opened door.
private static int makeSecondChoice(Prize[] doors, int firstChoice, int goatDoorOpened) {
int secondChoice = randomDoor();
while (secondChoice == firstChoice || secondChoice == goatDoorOpened) {
// Try again.
secondChoice = randomDoor();
}
return secondChoice;
}

// Pick a random door and put a Car there.
private static void pickRandomDoorForCar(Prize[] doors) {
// Start all goats.
Arrays.fill(doors, Prize.Goat);
// Pick a random for the car.
doors[randomDoor()] = Prize.Car;
}
// Start my random number generator.
static final Random random = new Random(System.currentTimeMillis());

// Pick a random door.
private static int randomDoor() {
return random.nextInt(Doors);
}
}


The results print:

Wins when switched = 37483
Wins when not switched = 24888
Proportion = 1.5060671809707489


Another way to explain it based on your "gut feeling".

Although this is the "psychological" way of viewing it (so no hard proof like already given above).

Imagine there were 100 doors, one prize is behind one of the doors. Now pick one door. Monty knows behind which of the doors the prize is and now opens all doors except two: your door and another one. Now you get the option to switch, your original door or the one door left closed... You see where I am going?

If you picked, say, door 15. Then all doors go open except 15 and e.g. 63. Doesn't that make 63 really suspicious for containing the prize, whereas your door remained closed only because you picked it initially?

I think this is a beautiful way to "explain" this problem without getting into the math too much. This way, you can convince people of the better option: switch, because you're getting better information. If you then explain the math behind it, then it will become an easy problem!

• I like to use picking the ace of spades from a deck as an example. Pick any card. I then turn over 50 cards, none of which are the ace of spades. Do you think I have the ace of spades, or do you think you have it? Commented Dec 18, 2013 at 16:45

The paradox changes only slightly when you increase the number of doors. The three-door model is most popular because it's the simplest statement of the problem (and the one normally seen on "Let's Make A Deal").

Basically, the reasoning behind the MHP is that, with $N$ doors, your original choice has a $\dfrac{1}{N}$ chance of being the car, which is relatively small. That means the chance that the car is elsewhere is $\dfrac{N-1}{N}$ (or $1 - \dfrac{1}{N}$, same thing). By opening one of these doors to reveal a goat, you don't change the math in the way you expect; the chance that you didn't pick the car (and thus it's behind another unopened door) is still N-1/N, but now that probability is evenly distributed between N-2 unopened doors, so the chance of any one unopened, unchosen door having the car is $\dfrac{N-1}{N(N-2)}$, which will be greater than $\dfrac{1}{N}$ for all $N > 2$.

So, with four doors, the probability that your original pick was correct is .25 ($1/4$), meaning the probability that you didn't pick the car (and that it's behind one of the three other doors) is .75 ($3/4$). Open a door to reveal a goat, and now, there is that same 75% chance that the car is behind either of the two remaining unchosen doors, so switching to either of them gives you a 37.5% chance of choosing correctly ($3/(4(2)) = 3/8$), while staying with your original choice gives you only the same 25% chance.

As you can see, the advantage (the percentage increase in probability of winning) starts shrinking pretty quickly; in the 3-door scenario, switching from your original choice gives you double the probability of winning, but with 4 doors the advantage is only 50% (.375/.25). With five doors, the winning probability of not switching is .2 while the winning probability of choosing any other unopened door is 4/15 = .2666, for a 33% advantage. With 6 doors, you have a 16.6% chance of guessing correctly on the first try and a 20.8% chance of winning if you switch, for a 25% advantage. We can project from this that the advantage of switching versus staying is $\dfrac{1}{N-2}$ for any $N>2$.

To add a bit to this discussion, there is a good book, "The Monty Hall Problem: The Remarkable Story of Math’s Most Contentious Brain Teaser" by Jason Rosenhouse (published in 2009), which covers all these variants and includes a variety of explanations for understanding them. The book also gives a nice history of the problem. Unfortunately it does not include the xkcd cartoon.

You should switch. By picking one of the doors first, the probability of getting a car is 1/4. Once Monty opens one door with the goat, the probability that the car is in one of the other 2 remaining doors is 1/2 * 3/4 = 3/8 > 1/4. So you should switch. The wikipedia article http://en.wikipedia.org/wiki/Monty_Hall_problem is a good read by the way.

• There are two remaining doors after Monty has opened one door. The 1/2 represents the 1 out of 2 doors remaining, and the probability 3/4 is due to the remaining probability (1 - 1/4) after you have chosen the first door and before Monty opens one door with the goat. Commented Dec 16, 2013 at 11:46

Here is an example a friend of mine once told me that I think really makes the monty hall problem really clear. Suppose there are one million doors, one with a golden Bugatti and the rest with an assortment of goats from all parts of the world.

At first you chose a random door. Then Monty opens all the other doors except for the one you have and one other. Then even your intuition tells you you should change the door.(this is different from the one you asked, but it's a great border-case example that is really intuitive).

• Following the reasoning behind the accepted answer, this happens to be a decent (albeit extreme) example. If you open all doors except for the one that has the car, you get (n-1)/n * 1 > 1/n. At n = 1 million, the left member is clearly much bigger than the right one. Commented Dec 16, 2013 at 17:59
• Note that this is only true if Monty intentionally chooses doors with goats. If you pick an arbitrary door, and Monty randomly opens 999,998 doors, and all of them happen to be goats, the probability of the car being behind each door is now 1/2. Commented Dec 16, 2013 at 19:13
• @Tanner:Then that wouldn't be the Monty Hall problem any longer.
– Dunk
Commented Dec 16, 2013 at 22:18
• @dunk Tanner is simply emphasising the importance of the host's knowledge. It's a crucial assumption in the formulation of the problem and should be made explicit when stating it. Commented Dec 17, 2013 at 13:52

The correct answer is, the problem isn't defined clearly enough to arrive at the "correct answer." Let's ignore the n doors, and k doors revealed for a moment, because they aren't essential for realizing that we don't know enough information to solve the question.

We need to choose any one of the doors. After we have chosen the door, Monty deliberately reveals one of the doors that has a goat and asks us if we wish to change our choice.

So should we switch the door we have chosen, or does it not matter if we switch or stay with our choice?

One of the problems with this question, is the motivations of the host are unknown. You specifically said that he revealed one of the doors, but not whether:

• He always reveals a door.

• He always reveals a losing door.

Without knowing that information, it is impossible to know if you should switch, not switch, or it doesn't matter.

The Monty Hall problem always confused me. And so, I coded it up in Matlab (2013a) to better understand it. In this version, the number of games played and N, the number of doors per game, are user settable parameters. I found 100,000 games gives relatively stable win/loss distributions for N = 100.

Code:

%Monty Hall problem assuming N doors, and N-2 doors
%opened prior to the final door choice.

clear;clc
rng('shuffle');

%    USER INPUT PARAMETERS
%------------------------------------------------------------
games = 100000;     %number of Monty Hall games (experiments)
N = 100;            %number of doors in each Monty Hall game
%------------------------------------------------------------

always_losses = 0;  %number of losses for always switch strategy
always_wins = 0;    %number of wins for always switch strategy
never_losses = 0;   %number of losses for never switch strategy
never_wins = 0;     %number of wins for never switch strategy

for ii = 1:games

prize = randi(N);
initial_choice = randi(N);

%(N-2 doors opened prior to final choice)
if initial_choice == prize
always_losses = always_losses + 1;  %always switch strategy
never_wins = never_wins + 1;        %never switch strategy
else
always_wins = always_wins + 1;      %always switch strategy
never_losses = never_losses + 1;    %never switch strategy
end

end

fprintf('\nWin fraction -- never switch:  %4.3f',never_wins/games);
fprintf('\nWin fraction -- always switch:  %4.3f\n\n',always_wins/games);


Results (for games = 100,000 and N = 100):

Win fraction -- never switch:  0.010
Win fraction -- always switch:  0.990


The computational results support Abramo's observation, namely, that Monty's help is not all that useful as the number of doors increases: The probability of winning approaches 1.0 for the "always switch" strategy as the number of doors approaches infinity.

Letting N = 3 reduces to the familiar Monty Hall game, and, produces the correct answer for that case.

My twist on explaining the Monty Hall problem:-

You pick one door.

Monty, instead of revealing a goat behind one of the other doors, offers you BOTH of them if you switch from your initial choice. Of course you switch, since this will absolutely double your chances.

And of course, at least one of the two doors that you switch to must have a goat, Monty just didn't show it to you. So what if he does or doesn't show it? We all know that it's there.

Choice wise, this is exactly the same as the original problem. The illusion is that you don't get the door that Monty opens. But effectively you do, it's just that you disregard it because it has no value.

@DwB

Your explanation would work if you chose your door AFTER you were shown a door that had a goat behind it.

Since you make your choice while there are 3 choices, the probability you choose the right door is 1/3 no matter if he shows you a goat or not.

If you choose one of the goats at first, you have a probability of 2/3 of choosing one of those right? So the beauty of this problem is that if you choose a goat first, and switch you will always get the car.

Think about it, if you choose one of the goats first, then the other goat will always get shown. If you switch then you will always switch to the car.

You want to choose a goat first to win this game by SWITCHING.(2/3) You want to choose a car fiRst to win this game by NOT SWITCHING.(1/3)

4 doors...

You choose a car at first(1/4) You choose a goat at first(3/4)

He opens 2 doors with a goat behind them, so your first choice and the last door is left.

If you chose the car first and switched now, you would lose.

If you chose any of the 3 goats initially, and now switched, you would win the car.

It just comes down to the fact you have a better chance of picking one of the goats initially, so assuming he shows all the other "bad choices" to you, it is better to switch your answer you chose originally.

The probabilities you win by switching your choice, assuming that Monty opens all the other doors accept for the original one you picked and one other one.

3 doors (2/3) 4 doors (3/4) 5 doors (4/5) 6 doors (5/6) 7 doors (6/7) 8 doors (7/8)

n doors [(n-1)/n] = 1 - 1/n

as n approaches infinity 1/n becomes 0, and the general probability = 1 - 0 = 1.

So if we were to play this game with an infinite amount of doors, and switch our choice, we would win 100% of the time!

This is an adaptation of an extremely short and simple solution to the Monty Hall problem which I posted here. I think it vastly simplifies matters in this case as well.

Of course the probability of winning if the contestant does not switch doors is $1/n$. So let's suppose the contestant does switch doors and let's break it into two cases: 1. the contenstant chooses the correct door initially, 2. he doesn't. The probability in each case respectively is $1/n$ and $\frac{n-1}{n}$. In the first case, switching doors loses. In the second case since another door is now eliminated the probability of winning by switching doors is $\frac{1}{n-2}$. Therefore the probability of winning by switching doors is $\frac{n-1}{n}\cdot\frac{1}{n-2}={\bf \frac{n-1}{n(n-2)}}$. Lastly, observe $\frac{n-1}{n(n-2)}>\frac{n}{n^2}=\frac{1}{n}$.

In the example where $n=4$, the probability of winning by switching is $\frac{4-1}{4(4-2)}=\frac{3}{8}$.