Step right up to Monty Hall's Hall of Doors! (Not endorsed by or affiliated with Monty Hall) Your chance to emperically get to the bottom of the Monty Hall Paradox! (Also not endorsed by or affiliated with Monty Hall).
This is a simulation that goes along with It's A New Car!: Intuition, Reality, and Goats in The Monty Hall Paradox, a little mathematics-popularization paper I wrote but never published, on the Monty Hall Paradox. Basically the MHP goes as follows: You get to choose from three doors. Behind one is a mega prize, like dinner with Linus Torvalds; behind the other two are lousy prizes, like Kenny G tickets. You pick a door, then Monty Hall (an old-time game show host) comes and opens another door, showing a lousy prize. You are then given a chance to switch (Jimmy Smitts) doors, or to stick with the one you had open.
Note that, according to Hall himself, this is not actually the way it worked on Hall's game show, Let's Make A Deal. Hall says he never gave anybody a chance to switch. That said, the problem as given is very interesting. What are your chances of winning if you switch, versus your chances of winning if you stick?
At first glance, it appears to make no difference. You should have a 50-50 chance either way. And, indeed, if you switch half the time, you will win half the time. However, the shocking truth is that if you switch all the time, you will win two-thirds of the time. Your chances are doubled by switching.
This seeming paradox is the result of not taking into account the difference between prior and posterior probability. If you don't care about what prior and posterior probability are, here is an intuitive explanation of how it works: When you choose a door the first time, that door has a 2/3 chance of being a door behind which is a lousy prize. Monty Hall can't open the door you picked, and he can't open the door with the good prize (for such is forbidden by the rules), so the two times out of three that you pick the wrong door initially, Monty has to open the other lousy door. When this happens, he leaves the good door ripe for the picking, and if you switch, you will win. The only time switching works against you is in the 1/3 of the time when you picked the right door in the first place.
Even if you don't believe my explanation, the simulation should emperically demonstrate to you that the 2/3-1/3 split is real. The simulation plays the Monty Hall game many, many times and tallys the results. You specify the number of games to play (any integer up to 10,000) and how often to switch (any percentage from 0 to 100). There are also various other options, described below.
You can specify whether you want to switch randomly or not. If you switch randomly, your switching or not switching on any round depends on whether or not a random number from 1-100 is higher than your switching percentage (eg. if you are switching 60% of the time and a 42 is generated, you will switch. If a 69 is generated, you won't). If you don't switch randomly, then a counter is used to keep track of when you should stop switching, reset after every 100 rounds (if you are switching 60% of the time, you will switch for rounds 1-60, then not switch for rounds 61-100, start switching again for 101-160, etc.) When the number of rounds is large, either method gives good results. However, if you are doing less than 100 rounds (statistically inadvisable), you need to use the random method.
By default, the simulated player chooses a random door in each round of the game. You can override this and force them to always pick door 1. It doesn't matter; either way will give the same results.
Finally, if you want to see the game in action, you can turn on logging. This prints out a short five-line summary of each round as it is played. At most the first 100 games are logged. This is so you don't waste time and bandwidth with a whole lot of logs you're not going to read.
Good switching percentage values to try are 0, 50, and 100. You can also start at 0 and gradually increase the switching percentage over multiple runs to 100, and see your win percentage start at 1/3 and gradually converge on 2/3. Also note that, no matter what the mix, you win about 2/3 of the games you switch on and 1/3 of the games you don't switch on, and that a close approximation to the total win percentage can be determined solely from the 2/3-1/3 assumption and your switching percentage.
If anyone is not convinced by this simulation, tell me what I have to do to make it convincing. I tried to make the source code to the program as readable and easy to understand as possible, but let me know if you have any difficulties.
This document (source) is part of Crummy, the webspace of Leonard Richardson (contact information). It was last modified on Saturday, August 18 2007, 03:11:30 Nowhere Standard Time and last built on Sunday, March 01 2015, 00:00:04 Nowhere Standard Time.
| Document tree: Site Search: |