OT: Monty Hall Simulation
INTRODUCTION:
I was intrigued by the discussion over the front page post about the Monty Hall Problem yesterday, and I thought that a simulation of the "game show" in question might help to demonstrate what is going on in the problem. I constructed the simulation (using Excel and the Analysis toolpak plugin) to test whether changing your choice of doors after the host reveals an incorrect door is a good idea. We will later perform the simulation with 50 iterations, and then 1,000 and 10,000. The steps are as follows:
SIMLUATION STEPS:
***************************************************************************************
STEP #1: Use a random number simulator to randomly select door #1, 2, or 3 as the door concealing the prize.
STEP #2: Use a random number simulator to randomly select door #1, 2, or 3 as the door the contestant thinks conceals the prize.
STEP #3: Use a random number simulator to randomly select one of the remaining doors as one of the doors the host "eliminates". This number/door can not be the same number selected in either of the previous two steps.
STEP #4: Change the contestant's choice to the door different than his initial choice and different than the one chosen by the host.
STEP #5: Test whether the new door is the same as the prize door selected in Step #1.
***************************************************************************************
EXAMPLE (ONE ITERATION OF SIMULATION)
For example, an iteration of this simulation might go as follows:
| STEP #1 | STEP #2 | STEP #3 | STEP #4 | STEP #5 |
| Prize door # | You choose door # | Host shows door # | Your new pick door # | Did you win? |
| (1=Yes, 0=No) | ||||
| 2 | 2 | 3 | 1 | 0 |
To preserve people's sanity, I won't write the Excel program codes used to ensure that the steps are effectively random and accurate. I was able to check that all of the above conditions were fulfilled (i.e. making sure that choices that can't overlap don't in the simulation). However, if you end up looking at the Excel file and have questions, I'd be happy to answer them.
TRIAL RUN OF 50 ITERATIONS
The good news about using Excel is that, once the code has been written and verified, it is extremely easy to produce iterations. Because we are limited by space, all that I will show here is a trial run of 50 iterations, which produced 33 successes (66%). I give the results from runs with more iterations below, as well as a link to the simulation file:
| STEP #1 | STEP #2 | STEP #3 | STEP #4 | STEP #5 |
| Prize door # | You choose door # | Host shows door # | Your new pick door # | Did you win? |
| (1=Yes, 0=No) | ||||
| 1 | 3 | 2 | 1 | 1 |
| 3 | 3 | 2 | 1 | 0 |
| 2 | 3 | 1 | 2 | 1 |
| 3 | 3 | 2 | 1 | 0 |
| 2 | 1 | 3 |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ing rooms gives you a 2/3 probability of winning. However, 50 trials still allows for a high amount of random fluctuation. We need to run more trials to ensure that random fluctuation is negligible (the Law of Large Numbers ensures that, in any experiment, the relative success/frequency in an experiment approaches the true probability as the number of iterations increase).
MORE ITERATIONS
Note: due to the randomness of these situations, each time the excel file is edited, the random numbers change, which in turn yields different (though similar results); the fluctuations will be greater for any runs with a small number of iterations (such as 50), and will shrink to a negligible amount for runs with sufficiently many iterations (such as 10,000). Keep this in mind if you download the simulation .xls file (see below).
50 iterations yield 33 successes -- 66% success rate
1,000 iterations yield 673 successes -- 67.3% success rate
10,000 iterations yield 6,675 success -- 66.75% success rate
SIMULATION FILE
Download the simulation .xls file by clicking here. You will need Excel with the Analysis Toolpak to read the file. Feel free to use it and make changes. I'd be happy to explain any of the techniques used to construct the simulation.
CONCLUSION
These numbers certainly suggest that 2/3 is indeed the correct probability, and that switching your choice is indeed the prudent decision. Simulations, however, are not proof, no matter how many iterations, so this simulation should merely be viewed as evidence and support for the "switching doors" conjecture (solid evidence, no doubt, but still lacking in the sense of an actual proof). (There is a theoretical proof, which several posters alluded to in the comments section of the original front page post.)
27 comments
|
5 recs |
Do you like this story?
Comments
I like smart people
"By MLB.TV, we can see J. Hamilton's homer, M. Young's clutch, and N. Feliz's explosive. All about Rangers things can be our interest"
--South Korean Rangers fan
Now
While all of this is rather pointless, because simple conditional probability tells you what’s going to happen, here is graphical explanation
AKA BuckyB
by Jobu. on Aug 27, 2010 9:59 AM CDT reply actions 1 recs
This picture was immensely helpful.
Certainly helps to see it as a concrete problem.
by Past A Diving Michael Young on Aug 27, 2010 11:26 AM CDT up reply actions
We could probably do a proof pretty easily...
but I’m not sure that people would believe it… or even be able to read it.
You are right
on both counts . . . simulations take the mystery out of it, or at least that’s the idea
Back from a blogging sabbatical to write a few posts here and there . . .
"Baseball, it is said, is only a game. True. And the Grand Canyon is only a hole in Arizona. Not all holes, or games, are created equal." --George Will
Makes me fell like I am back in class...
And next week are going to discuss optimizational modeling and stochastic programing…
JD’s like, "you want some fucking pitching? Here’s all the pitching you can stand. Now choke on it, bitches!"- RCCook
what did/do you study?
Back from a blogging sabbatical to write a few posts here and there . . .
"Baseball, it is said, is only a game. True. And the Grand Canyon is only a hole in Arizona. Not all holes, or games, are created equal." --George Will
I have a degree in Decision Science which is an Applied Stats/OR setup
I am finishing a masters in Decision Technologies, which is Applied Stat + OR + Technology proliferation and trying to decide if I want to start a Management Science PhD.
UNT’s Applied Stat Dept is one of the better ones in the south and in certain areas a top 10 in the nation.
JD’s like, "you want some fucking pitching? Here’s all the pitching you can stand. Now choke on it, bitches!"- RCCook
cool
I’m in mathematics at OU, and I’ve also done some work in applied stat, though it’s not my primary focus
"Baseball, it is said, is only a game. True. And the Grand Canyon is only a hole in Arizona. Not all holes, or games, are created equal." --George Will
I have no idea what's going on right now.
"Drinks are on me if Lewis posts >168IP and an era lower than 3.86." by RangerMad on Jan 20, 2010 12:36 PM PST
One difficulty
Is that there is an important assumption that the host will pick a non-car door every time. If you don’t spend time thinking about the impact of that, 50% seems like a very rational choice.
AKA BuckyB
Hm.
What would the impact of his picking one of the two remaining doors at random.
In the 33% of the time you’re right: he shows you a door with a goat. If you switch, you have a 0% chance of winning. If you stay, you have a 100% chance of winning.
In the 66% of the time you’re wrong: 50% of the time he shows you the door with the other goat. If you switch, you have a 100% chance of winning; stay, 0%. The other 50% of the time he shows you the car. You (presumably) decide to switch, and have a 100% chance of winning. (I’d actually never even thought about it this way because if the the host can show you the door with the car, the rest of the problem makes no sense. If you’re offered the choice to switch at that point, you’re going to take it; if you’re not offered, you instantly lose.)
Totals:
Chance of winning when staying = .33*1 + .66*.5*0 + .66*.5*0 = 33%.
Chance of winning when switching = .33*0 + .66*.5*1 + .66*.5*1 = 66%
So that doesn’t affect it at all after all.
Now, what if he shows you one at random, possibly including your own? I don’t have time to break that one down right now, but I’m guessing it would still favor switching (at least in the cases where you weren’t already right and he picks your door and shows you you were right) because in the case where you were wrong and he picks your door, you have a 0% chance if you stay.
nice explanation
"Baseball, it is said, is only a game. True. And the Grand Canyon is only a hole in Arizona. Not all holes, or games, are created equal." --George Will
Looks like a 5/9 chance of winning when switching if he opens any door (yours included) at random.
I was looking at it backward thinking that he-sometimes-picks-your-door-when-you’re-wrong thing would help you; then you only have a 50% chance if you switch. This hurts you, because you can still never win more than 33% when staying, and this introduces a 1/9 chance that you’ll get it wrong the first time, be shown you were wrong, and guess wrong on the 2 remaining doors.
Chance of winning when staying: 3/9
Chance of winning when switching: 5/9
and a 1/9 chance of losing regardless (switching to the wrong one after being shown you were wrong)
My gut tells me you have 7/9 chance of winning this scenario
Lets assume we all agree that as originally stated, you have a 66% (2/3 = 6/9) chance of winning when switching. The only benefit to you in this new scenario where he shows you any door at random occurs if you have made a correct initial choice (33%) and he also opens your door (33%). 1/3 * 1/3 = 1/9. Presumably, if you see that you have already picked the correct door, you do not switch. So, 1/9 guaranteed win, plus 6/9 likely hood when switching is 7/9.
"What ... 92 miles per hour?" Feldman scoffed. "That's not gas. Feliz throws gas."
"If I had caught it, the force would have taken me through the fence." -- Rockies outfielder Ryan Spilborghs about a Nelson Cruz line drive.
by NorCalRangersFan on Aug 27, 2010 6:14 PM CDT up reply actions
Gut is wrong
I’m only going to model where you have “randomly” chosen the first door.
1* 0 0 You correctly pick the door and he shows it to you! Winner! 1 0* 0 You correctly pick the door and he shows you an empty door. You play the odds, switch and lose! 1 0 0* You correctly pick the door and he shows you an empty door. You play the odds, switch and lose! 0* 1 0 You do not pick the correct door and he shows you that you missed. You randomly switch to a remaining door and have a 50/50 shot at winning. 0 1* 0 You do not pick the correct door, but he opens the winning door. You randomly switch to the winner! 0 1 0* You do not pick the correct door, and he opens a losing door. You play the odds and switch to the remaining door and are a winner! 0* 0 1 You do not pick the correct door and he shows you that you missed. You randomly switch to a remaining door and have a 50/50 shot at winning. 0 0* 1 You do not pick the correct door, and he opens a losing door. You play the odds and switch to the remaining door and are a winner! 0 0 1* You do not pick the correct door, but he opens the winning door. You randomly switch to the winner!
So, 5x always win, 2x 50/50 win, 2x lose = 6/9 chance of winning. 66%!
"What ... 92 miles per hour?" Feldman scoffed. "That's not gas. Feliz throws gas."
"If I had caught it, the force would have taken me through the fence." -- Rockies outfielder Ryan Spilborghs about a Nelson Cruz line drive.
by NorCalRangersFan on Aug 27, 2010 6:36 PM CDT up reply actions
Crap!
Cut/paste that block into a text editor (Notepad, TextEdit) to see all the text.
"What ... 92 miles per hour?" Feldman scoffed. "That's not gas. Feliz throws gas."
"If I had caught it, the force would have taken me through the fence." -- Rockies outfielder Ryan Spilborghs about a Nelson Cruz line drive.
by NorCalRangersFan on Aug 27, 2010 6:38 PM CDT up reply actions
Explaining the columns...
Each column is a door. A ‘1’ indicated the winning door. ‘*’ indicates the door that is opened by Monty.
"What ... 92 miles per hour?" Feldman scoffed. "That's not gas. Feliz throws gas."
"If I had caught it, the force would have taken me through the fence." -- Rockies outfielder Ryan Spilborghs about a Nelson Cruz line drive.
by NorCalRangersFan on Aug 27, 2010 6:41 PM CDT up reply actions
That first one—get it right, have it shown to you—is where I went wrong.
I got mixed up on how to count it when trying to come up with an overall winning percentage if you always switch, since you’d lose if you switched, but you’d also be an idiot to switch, so my 5/9 odds if you switch were correct but silly.
So yeah, you’re right, the overall odds of winning are still 2/3 if you play it right, as that lost 1/9th from the 2 50% got it wrong and have it shown to you cases are transferred to the got it right and have it shown to you case, where you no longer switch.
Door #0?
In several of your simulations, you have the host showing door #0. It appears that door 0 is only shown when you select door 2 and it does already have the car behind it.
Is this a bug?
Good catch
I’m surprised I didn’t notice it. The fix should be pretty easy, I’ll let you know when it’s been updated.
"Baseball, it is said, is only a game. True. And the Grand Canyon is only a hole in Arizona. Not all holes, or games, are created equal." --George Will
fixed
Turns out the problem wasn’t with the simulation (I opened the file and didn’t see any zeros in STEP#3 in any of the iterations). Instead, the bug was in how the SB platform pasted the table (somehow the formatting got screwed up). So I just repasted the table and double checked that it worked this time.
"Baseball, it is said, is only a game. True. And the Grand Canyon is only a hole in Arizona. Not all holes, or games, are created equal." --George Will
By The Way
Ran this will 1 million iterations and you get the same results. It makes sense, if you choose the goat and switch, you win. You choose a goat 2/3 of the time. Just takes some thinking to get to that point.
did you use
the same simulation file? I thought about going to one million . . . but got enough by dragging the mouse down to the cell A10,006
"Baseball, it is said, is only a game. True. And the Grand Canyon is only a hole in Arizona. Not all holes, or games, are created equal." --George Will
I don't understand what you are saying right now...
….so I’m gong to assume you are disrespecting me.

by 



























