Return to more brain teasers.
It seems like the answer should be 1/2 but actually the chances of it being in the curtain that Monty offers you are 2/3 or 66.67%. Since there are 3 curtains and you pick one, you will be correct 1/3 of the time. The chances that it is in the two other curtains is 2/3. Because Monty always opens an empty curtain the chance of the final curtain that you can switch to does not change and is still 2/3. If he opened a random curtain then you would have the same odds if you switched or not.
If you always stick with your initial guess, when do you win? Only when you pick the car with your initial guess. This is 1/3 of the time. If you always switch from your initial guess, when do you win? Only when you don't pick the car with your initial guess. This is 2/3 of the time. If he was opening a random door then it wouldn't make any difference, it would be 1/3 of the time either way because 1/3 of the time he would open the curtain with the car.
Here's another way of looking at it.
There are a million doors. You choose one of them. Monty opens 999,998 empty doors leaving the one you chose and another one. Do you really think you picked the car on your first try and shouldn't switch?
From the sci.math.faq on the Monty Hall Problem, version 7.5, dated: 2-20-98.
There are several ways to convince yourself about why it pays to switch. Here's one. You select a door. At this time assume the host asks you if you want to switch before he opens any doors. Even though the odds that the door you selected is empty are high (2/3), there is no advantage on switching as there are two doors, and you don't know thich one to switch to. This means the 2/3 are evenly distributed, which as good as you are doing already. However, once Monty opens one of the two doors you selected, the chances that you selected the right door are still 1/3 and now you only have one door to choose from if you switch. So it pays to switch.
Believe me, this is correct. Here are some other discussions about it.
http://www.cut-the-knot.org/hall.shtml
NOTE: If you still don't believe, I am willing to discuss this with you. However, I will expect you to read the above websites, do the following simulation with cards, and I expect you to sit back and think about it before questioning. If you want, do it with 5 doors and you will see it faster. There are things that are probably wrong with my teasers page and you can argue about the wording of this or other problems, but this one is correct.
If you would like to see this in action then do the following with a deck of cards and a friend. Please let me know if you can think of an easier way of doing this.
So I wrote a quick little C program to simulate the problem and show the answer. Enjoy.
#define NUM_TRIES 100000 /* number of iterations to run */ #define NUM_DOORS 3 /* number of doors in the problem */ int main() { long stay_won_c = 0, stay_lost_c = 0, switch_won_c = 0, switch_lost_c = 0; long try_c, total, car_door, choice_door, open_door, new_choice, switch_b; int open_c, open_flags[NUM_DOORS]; /* initialize random generator */ srandom(time(0L) ^ 0xDEADBEEF); for (try_c = 0; try_c < NUM_TRIES; try_c++) { car_door = random() % NUM_DOORS; /* put the car behind a door */ choice_door = random() % NUM_DOORS; /* choose a door */ /* now monty opens empty door(s) */ for (open_c = 0; open_c < NUM_DOORS; open_c++) open_flags[open_c] = 0; for (open_c = 0; open_c < NUM_DOORS - 2; ) { open_door = random() % NUM_DOORS; if (open_door == car_door /* do not open the car door */ || open_door == choice_door /* do not open the choice door */ || open_flags[open_door]) { /* do not open an already open door*/ continue; } open_flags[open_door] = 1; open_c++; } switch_b = random() % 2; /* should we switch or stay? */ /* if we are switching then choose another door that has not been opened */ if (switch_b) { while (1) { new_choice = random() % NUM_DOORS; /* make sure we are not chosing the old choice or an open door */ if (new_choice != choice_door && (! open_flags[new_choice])) break; } choice_door = new_choice; } /* now, see if we won */ if (choice_door == car_door) { /* we get the car! */ if (switch_b) switch_won_c++; /* switching won the car */ else stay_won_c++; /* staying won the car */ } else { /* we get the goat */ if (switch_b) switch_lost_c++; /* switching lost */ else stay_lost_c++; /* staying lost */ } } /* print out the results */ total = switch_won_c + switch_lost_c; printf("Switch won %ld (%ld%%), lost %ld (%ld%%)\n", switch_won_c, (switch_won_c * 100 / total), switch_lost_c, (switch_lost_c * 100 / total)); total = stay_won_c + stay_lost_c; printf("Stay won %ld (%ld%%), lost %ld (%ld%%)\n", stay_won_c, (stay_won_c * 100 / total), stay_lost_c, (stay_lost_c * 100 / total)); return 0; } /* end of program */
Here's a Perl version of the simulator.
my $NUM_TRIES = 100000; # number of iterations to run my $NUM_DOORS = 3; # number of doors in the problem my $stay_won_c = 0; my $stay_lost_c = 0; my $switch_won_c = 0; my $switch_lost_c = 0; # initialize random generator srand(time ^ 0xDEADBEEF); for (my $try_c = 0; $try_c < $NUM_TRIES; $try_c++) { my $car_door = int(rand($NUM_DOORS)); # put the car behind a door my $choice_door = int(rand($NUM_DOORS)); # choose a door my $open_door; while (1) { $open_door = int(rand($NUM_DOORS)); last unless ($open_door == $car_door # do not open the car door || $open_door == $choice_door); # do not open the choice door } my $switch_b = int(rand(2)); # should we switch or stay? # if we are switching then choose another door that has not been opened if ($switch_b) { my $new_choice; while (1) { $new_choice = int(rand($NUM_DOORS)); # make sure we are not chosing the old choice or an open door last if ($new_choice != $choice_door && $new_choice != $open_door); } $choice_door = $new_choice; } # now, see if we won if ($choice_door == $car_door) { # we get the car! if ($switch_b) { $switch_won_c++; # switching won the car } else { $stay_won_c++; # staying won the car } } else { # we get the goat if ($switch_b) { $switch_lost_c++; # switching lost } else { $stay_lost_c++; # staying lost } } } # print out the results my $total = $switch_won_c + $switch_lost_c; printf("Switch won %ld (%ld%%), lost %ld (%ld%%)\n", $switch_won_c, ($switch_won_c * 100 / $total), $switch_lost_c, ($switch_lost_c * 100 / $total)); $total = $stay_won_c + $stay_lost_c; printf("Stay won %ld (%ld%%), lost %ld (%ld%%)\n", $stay_won_c, ($stay_won_c * 100 / $total), $stay_lost_c, ($stay_lost_c * 100 / $total)); /* end of program */
Free Spam Protection Android ORM Simple Java Zip JMX using HTTP Great Eggnog Recipe