Recognitions:
Gold Member

## 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?
The solution is said to be yes, because you have 1/3 probability to stay and 2/3 probability to switch.

The answer to this problem has annoyed me to an extent. Why is the host completely ignored as a variable to calculate the probability? I think there is an error in this solution due to the fact that the host and his actions are completely ignored.

Example:
 ' does not switch For c = 1 To 10000 car = Rand(0, 2) If car = 0 Then x = x + 1 End If Next c 'always switches For c = 1 To 10000 car = Rand(0, 2) If car = 2 Then y = y + 1 ElseIf car = 1 Then y = y + 1 End If Next c

This algorithm will create the same result, 1/3 does not switch, 2/3's switch.

Now if I introduce the host as a variable:
 For c = 1 To 10000 car = Rand(0, 2) If car Xor 1 = 0 Then host = 2 ElseIf car Xor 2 = 0 Then host = 1 End If If host = 1 Then If car = 0 Then n = n + 1 End If ElseIf host = 2 Then If car = 0 Then n = n + 1 End If End If Next c 'my version - switch is always made For c = 1 To 10000 car = Rand(0, 2) ' host must decide which door to open based on the location of car. Since he always opens a losing door.... If car Xor 1 = 0 Then 'if car is in door 1 host = 2 'host will open door 2 ElseIf car Xor 2 = 0 Then host = 1 End If If host = 1 Then ' if host opens door 1 If car = 2 Then 'switch is made to door 2, is there a car? z = z + 1 ' win End If ElseIf host = 2 Then If car = 1 Then z = z + 1 End If End If Next c
With this algorithm, the probability changes to 1/3 and 1/3 and shows that you have equal chance to win, if you do or do not switch doors.

 PhysOrg.com science news on PhysOrg.com >> Hong Kong launches first electric taxis>> Morocco to harness the wind in energy hunt>> Galaxy's Ring of Fire
 Recognitions: Gold Member 1: Visual Basic is a horrible language 2: Why are you using car Xor 1 =0 instead of car = 1 3: I've a feeling that car Xor 1 =0 might parse as car Xor (1 =0)

Hi SixNein,

 The solution is said to be yes, because you have 1/3 probability to stay and 2/3 probability to switch.
It is not clear what you mean here. You don't have probability of switching, you either switch or you don't, with probability of 1.

The confusion with this problem stems with people analyzing the strategy of switching and not switching at the same time. The probability that you win if you switch is 2/3, and probability that you win if you don't switch is 1/3. These add to 1, which leads people to believe that these probabilities are from the same probability distribution, but THEY ARE NOT! The fact that they add to 1 is a coincidence, and if you increase the number of doors beyond 3 this will no longer be true.

To analyze this problem, you have to pick a strategy and find the probability of winning and loosing assuming that you always follow that strategy.

Assume that you always switch the doors. Now observe that you will win if and only if your first pick is a goat (make sure you understand why). The probability that your first pick is a goat is 2/3, therefore you win with probability of 2/3. Because you either win or you loose, the probability of loosing when following this strategy is 1/3. If you chose a goat on your first pick, the host does not have a choice in which door he will open, he has to open a door with the other goat. If you choose the car on your first pick, then you will loose no matter what door the host opens, because you always switch.

Now lets say you don't switch, and you always stick with your first pick. Then you will win if you picked the car on your first pick, no matter what the host does. So you win with probability of 1/3, and loose with probability of 2/3.

Which strategy is the best? The first strategy gave probability of winning of 2/3 and the second of 1/3, therefore always switching is better. Again, the fact that these add to 1 is coincidence, as will be seen now.

Suppose you generalize this problem in the following way: you have n doors, with n-1 goats and 1 car. You choose a door at random. The host then chooses a random door from the doors with the goats and opens it. Then you can either stick with your first pick, or pick another door at random from remaining doors. Which of these two strategies is better?

Suppose you always switch. Call this strategy 1. You loose if your first pick was a car, and you also loose if first you picked a goat and then upon switching doors, you again ended up on a goat. The probability of you loosing is then

$$P_1 (loose) = \frac{1}{n} + \frac{n-3}{n-1} \left( \frac{n-1}{n} \right)$$

(I will denote probabilities from this strategy with subscript 1). You win if you first picked a goat and then you picked a car, which is:

$$P_1 (win) = \frac{n-1}{n} \left( \frac{1}{n-2} \right)$$

You can check that these two add to 1, and also that they give consistent results when n=3.

Now suppose, as strategy 2, you always stay on your first pick. Then you win if and only if your first pick is a car, with probability:

$$P_2 (win) = \frac{1}{n}$$

And you can clearly see now that the probabilities of winning from both strategies don't add up to 1 as they did for the case of n=3:

$$P_1 (win) + P_2 (win) = \frac{2n-3}{n(n-2)} \ne 1$$

And also observe that since $$\frac{n-1}{n-2} >1$$ , we have that $$P_1(win) > P_2(win)$$, so that strategy 1 gives a greater probability of winning. Therefore even in this generalized problem, it is always better to switch to a random door after the host opens a random door with a goat.

To simulate this, write a program for general problem of n doors, and then run for various values of n, including n=3. Here is a full simulation of this problem in C++, which simulates the strategy of always switching doors. The numerical results I get are consistent with the above formulas:

Code:
#include <cstdlib>
#include <iostream>
using namespace std;

// returns random integer in range [0,m]
// including 0 and m
size_t random(size_t m)
{
return rand() % (m+1);
}

// simulate one game assuming always switching doors.
// reeturn true if won the car.
bool event()
{
size_t const n = 3;       // number of doors

size_t car = random(n-1); // car is at random door

// first pick:
size_t pick1 = random(n-1);
if (pick1 == car)         // since I'm switching, first pick of car means lost
return false;

// host picks a door with a goat and different from my first pick
size_t host;
do {
host = random(n-1);
} while (host == pick1 || host == car);

// second pick, different from my first pick and the door hos has opened
size_t pick2;
do {
pick2 = random(n-1);
} while (pick2 == pick1 || pick2 == host);
// return true if second pick is the car
return pick2 == car;
}

// simulate this game given number of times
double repeat(size_t times)
{
size_t sum = 0;
for (size_t i=0; i < times; ++i)
sum += event();
return (double)sum/times;
}

int main()
{
cout.precision(12);
cout.setf(ios_base::fixed, ios_base::floatfield);
srand(time(0));
double p = repeat(100000);
cout <<"Probability of winning the car is " <<p <<endl;
}

Recognitions:
Gold Member

## Monty Hall problem

 Quote by chronon 1: Visual Basic is a horrible language 2: Why are you using car Xor 1 =0 instead of car = 1 3: I've a feeling that car Xor 1 =0 might parse as car Xor (1 =0)
Ah I see, it's been a mistake on my part.

Hi everyone! Attached is an .xls who explains better the problem showing probablity of ocurrence of each single possibility on the game and it's result.

Bassically, you are always assuming that you have 1/3 of chances to win. But according to game's rules, you are always 1/2. These are the rules:

1) You are going to choose between 3 doors
2) Host is going to open a door (but not the one you've choose, useless information), who will have a goat inside. Then he'll make you choose between the others 2 doors, one of them will have a goat, the other a car.

The rules are always 50% chances of winning, since the beggining.

Look at all the ecuations around the forum. For example: Mikepol: When you've wrote:
P(loose)=1/n + [(n-3)/(n-1)] [(n-1)/n)

What represents 1/n?
It's actually a 1/3 chance that you choose the door with the goat, and the host will open that door at 1st chance?
Attached Files
 Monty.xls (19.0 KB, 9 views)

Mentor
 Quote by Otropablo These are the rules: 1) You are going to choose between 3 doors 2) Host is going to open a door (but not the one you've choose, useless information), who will have a goat inside. Then he'll make you choose between the others 2 doors, one of them will have a goat, the other a car. The rules are always 50% chances of winning, since the beggining.
Those are not the rules, and those are not the odds. You have several things wrong:
• The contestants are not forced to choose a different door. They can either stick with the door they chose originally or switch to the remaining door after Monty shows a goat.
• You are making a classical statistical error in applying the principle of indifference where it is not valid to do so. Example of an invalid application: The sun will rise tomorrow or it won't. Therefore there is a 50% chance that the sun won't rise tomorrow.
• Just as an aside, you said "but not the one you've choose, useless information". Showing the contestant what was behind the original door would be quite useful information. If Monty showed me that a car was behind the door that I chose originally I would not switch to one of the other two doors.

* The contestants are not forced to choose a different door. They can either stick with the door they chose originally or switch to the remaining door after Monty shows a goat.

Exactly. They WILL get to 2d stage, and choose between SWTCH or STAY (2 choices) between 2 doors, one of them has a goat, the other a car.

* You are making a classical statistical error in applying the principle of indifference where it is not valid to do so. Example of an invalid application: The sun will rise tomorrow or it won't. Therefore there is a 50% chance that the sun won't rise tomorrow.

But the sun will rise tomorrow, there a 100% chance of that. And there's a 100% chance that you'll have to choose between 2 doors. Please check the .xls, there's every chance.

* Just as an aside, you said "but not the one you've choose, useless information". Showing the contestant what was behind the original door would be quite useful information. If Monty showed me that a car was behind the door that I chose originally I would not switch to one of the other two doors.
Exactly, but Monty don't show you the one you've choose, he showes you one which don't care (he has already decided he'll show you goat, no matter what you choose).

 Quote by D H Those are not the rules, and those are not the odds. You have several things wrong:The contestants are not forced to choose a different door. They can either stick with the door they chose originally or switch to the remaining door after Monty shows a goat. You are making a classical statistical error in applying the principle of indifference where it is not valid to do so. Example of an invalid application: The sun will rise tomorrow or it won't. Therefore there is a 50% chance that the sun won't rise tomorrow. Just as an aside, you said "but not the one you've choose, useless information". Showing the contestant what was behind the original door would be quite useful information. If Monty showed me that a car was behind the door that I chose originally I would not switch to one of the other two doors.

 DH, give me some hope; Try to correct me on this: Car is behind A: P(win) = P(1/3 Ben chooses A, 1/2 host shows C, 1/2 Ben stays) + P( 1/3 Ben chooses A, 1/2 host shows B, 1/2 Ben stays) + P(1/3 Ben chooses B, 1/1 host shows C, 1/2 Ben switches) + P(1/3 Ben chooses C, 1/1 host shows B, 1/2 Ben switches) P(win) = P(1/3*1/2*1/2) + P(1/3*1/2*1/2) + P(1/3*1/1*1/2) + P(1/3*1/1*1/2) = 1/2 and: P(loose)= P(1/3 Ben chooses A, 1/2 host shows C, 1/2 Ben switches) + P(1/3 Ben chooses A, 1/2 host shows B, 1/2 Ben switches) + P(1/3 Ben chooses B, 1/1 host shows C, 1/2 Ben stays) + P(1/3 Ben chooses C, 1/1 host shows B, 1/2 Ben stays) P(loose) = P(1/3*1/2*1/2) + P(1/3*1/2*1/2) + P(1/3*1/1*1/2) + P(1/3*1/1*1/2) = 1/2 Car has 1/3 chances to be at A; So repet it for car in B and C and you'll get to P(win)=1/3 * 1/2 + 1/3 * 1/2 + 1/3 * 1/2 = 1/2 P(loose)= 1/3 * 1/2 + 1/3 * 1/2 + 1/3 * 1/2 = 1/2 Check on http://montyhallproblem.com/ They actually said "Finally, you may be interested to know how I approached the problem, and solved it. I was presented the problem, and also told that the obvious solution is wrong. I was aware of the controversy. What did I do? Well, normally I’m pretty much a theorist, but in this case it occurred to me that discovering the correct solution by experiment would save me some time. So I wrote a short program. Then I figured out why switching works. It baffles me that there are people who will insist that it’s 50/50, and never make the effort to verify their claim." Switching don't work, if you try the same without switching it'll be 50% too. What works is the host, who deletes one of the bad options for free. Your chances are now 50% to win and you didn't faced any danger, who cares your first choice? Or just try it at http://www.grand-illusions.com/simulator/montysim.htm It's not mine: It'll show you the 50% of your kepts win and so the 50% of your changes

Mentor
 Quote by Otropablo DH, give me some hope; Try to correct me on this: Car is behind A: P(win) = P(1/3 Ben chooses A, 1/2 host shows C, 1/2 Ben stays) + P( 1/3 Ben chooses A, 1/2 host shows B, 1/2 Ben stays) ...
That is wrong. The probability is not 1/2 that Ben stays and 1/2 that Ben switches. Those are the two distinct strategies; you need to compute the probabilities for each separately.

First, the "keep" strategy. Here you choose a door initially and never change doors after Monty shows you a goat. You had no prior information before choosing the door. The principle of indifference does apply here. There is a 1/3 chance that the chosen door hides a car. Being shown a goat after the fact doesn't change that probability. Thus P(win|keep) = 1/3.

Now let's look at P(win|change). Here you choose a door initially and always change doors after Monty shows you a goat. The principle of indifference still applies on the initial choice, so there is a 1/3 chance that your switching will be from a winner to a loser. How about the 2/3 of the time that your initial choice was a goat? Monty has to show you a goat, and there is only one goat left. Monty is forced to tell you where the car is two times out of three! Switching will always loses on the 1 out of 3 times you initially chose the door hiding the car. On the other hand, switching will always win in the 2 out f 3 times you initially chose a door hiding a goat. P(win|change)=2/3.

 Check on http://montyhallproblem.com/ They actually said "Finally, you may be interested to know how I approached the problem, and solved it. I was presented the problem, and also told that the obvious solution is wrong. I was aware of the controversy. What did I do? Well, normally I’m pretty much a theorist, but in this case it occurred to me that discovering the correct solution by experiment would save me some time. So I wrote a short program. Then I figured out why switching works. It baffles me that there are people who will insist that it’s 50/50, and never make the effort to verify their claim."
You apparently do not understand what he said on that page because he said what everyone here has said: Switching is the winning strategy. What baffles is is people like you who will insist that its 50/50.

 Or just try it at http://www.grand-illusions.com/simulator/montysim.htm It's not mine: It'll show you the 50% of your kepts win and so the 50% of your changes
I just did the experiment 40 times, 20 with the "keep" strategy and 20 with "change". The outcome: Keep: 5 cars, 15 goats; change: 13 cars, 7 goats. I obviously did much better with the change strategy.

 Thanks a lot DH and sorry for my obstinance. I finally see the problem clearly thanks to yours (and others) explanations. I really appreciate the time you've spend in teaching me this logic. Best regards and I promes to take more time for analisys before posting like that again! Thanks a lot again!