In the movie
21, Kevin Spacey brings up a math/logic/probability problem called the Game Show Host Problem.
In the movie the problem was described something like this: You are a contestant on a game show and you have to choose between three doors, one of which has a new car behind it. The other two doors have goats behind them. The game show host tells you to pick a door. You do so, at which point the game show host opens up one of the other two doors to show you a goat. The host then asks you if you would like to switch your choice to the other closed door. The question then is: Should you switch your choice, or should you stick with your original choice?
The answer in the movie was that you should switch, because you have a 2/3 chance of winning if you switch, and a 1/3 chance if you stick with your original choice. Mathematically that is correct (you can see
an explanation here). But they left out an important assumption, which is that the game show host always asks you if you would like to switch doors. If the game show host's behavior is unpredictable, then the probability is unpredictable, but if we know that the host always asks if you want to switch doors, then you do have a 2/3 chance of winning by switching.
The simplest explanation I can come up with is that when you make your initial choice, you clearly have a 1/3 chance of being correct. Then, even after the game show host opens one of the doors, your initial choice still had a 1/3 chance of being correct, so the other door must have a 2/3 chance of being correct, since it's the only one left.
I was discussing the problem with my roommate after watching the movie. It's kind of a hard thing to grasp, because it seems like it should be a 50% probability either way. But it's not.
So, to "prove" the results, and also to prove how nerdy I am, I wrote a quick
Perl program to simulate the results. I'm pretty rusty since I haven't done any programming to speak of in the last couple of years, so it took 150 lines when a good programmer could probably have done it in 15.
But sure enough, when running the program, you win approximately 2/3 of the time if you switch doors, and approximately 1/3 of the time if you don't switch. Check it out:
% ./goat_problem.pl --switch=true --iterations=10000000
Switching... Won 6667355 out of 10000000 Times!
% ./goat_problem.pl --switch=false --iterations=10000000
NOT Switching... Won 3333678 out of 10000000 Times!