# Puzzle 6 | (Monty Hall problem)

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?

Source: http://en.wikipedia.org/wiki/Monty_Hall_problem

**Solution:**

If you switch, you get the car with probability 2/3. So switching is always a good choice. Refer this MIT video lecture for great explanation. Refer online editable Monty hall simulation to play with how things change with multiple doors, prizes etc.

Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above

If “the host, who knows what’s behind the doors” opens a door which has a goat, then the probability the car was behind that door was 0 before the door was opened (actually, as soon as the car was placed behind a door). Since the host knows which door has the car behind it, then the probability that the car is behind that door is 1. Hence, the probability of winning by switching is either 0 (if the host knows that door does not have the car behind it) or 1 (if the host knows that door does have the car behind it), not 2/3.

__Proof__–

Let E_{1}, E_{2} and E_{3} be 3 Events, such that

E_{1}=Car is behind door 1,

E_{2}=Car is behind door 2,

E_{3}=Car is behind door 3

And consider another event A, such that A=The host opens door 3

So, we basically have to find the probability P(E_{1} |A), which basically means “What is the probability that the car is behind door 1, given that the host has already opened door 3”.

So, according to Bayes’ theorem, we can write this probability as-

Now here, we have probabilities P(E_{1})=P(E_{2})=P(E_{3})=1/3, since it was previously equally likely that the car can be either behind door 1, or door 2, or door 3.

Next, P(A│E_{1})=Probability that that the host has opened door 3, given the car is behind door 1 = 1/2, since the host can open door 2 or door 3, since they both don’t have the car behind them.

And, we have P(A│E_{2})=Probability that the host has opened door 3, given that the car is behind door 2 = 1, because if the car is behind door 2, then the only door that the host can open is door 3.

And, P(A│E_{3})=Probability that the host has opened door 3, given that the car is behind door 3 = 0

This is because the probability of the host opening the door that has the car behind it was 0 according to the question, since he never opens the door having the car behind it.

So, putting all these values in the above formula, we get-

Hence, we can see that the there is 1/3 chance that the car is behind door 1 ⇒ there is 1−1/3=2/3 chance that the car is behind door 2.

Therefore, you should switch.