6 ms·
Monty Hall Problem Simulation
- tomalpha 9y agoThis has always fascinated me. I can understand the reasoning behind it, but still don’t completely “get” it. It seems so counter intuitive. I ended up writing code to simulate it too. Glad it’s not just me that need that extra level of proof. Edit: I very much appreciate the willingness to try and explain this below. Many have tried before; not least my poor despairing A-level maths teacher back in the day.
- ehsankia 9y agoIt's much clearer if instead of 3 doors, you use a big number, let's say 100 doors. So you pick one of the 100 doors, then the host closes 98 other doors that are guaranteed to be wrong. Now, you can chose between that one door you started with, or go with the one door that's left after the host removed 98 wrong doors. Intuitively, which one is more likely to be right? The one you randomly picked out of 100, or the one left after 98 doors were discarded?
- tomalpha 9y agoThanks and yes it does make more sense when posed like that. I still (as something I consider a personal failing) end up intuiting a probability of 50%. It remains fascinating to me how different people’s brains perceive the world differently. At least I tell myself that when struggling through subjects I find tougher :)
- xorcist 9y agoThat only makes sense once you already know and internalized the right answer. Had the original problem been stated "the host closes all doors guaranteed to be wrong" it would not be remotely as unintuitive.
- deleted 9y ago[deleted]
- deleted 9y ago[deleted]
- yarg 9y agoDivide the doors into two sets, the door that you chose and those that you did not. There is a 1/3 chance that the correct door is in the first set. There is a 2/3 chance that the correct door is in the second set. You are then told that one of the doors in the second set is not the correct door. This new information has no impact on the probabilities associated with the complete sets - it only impacts the probabilities within the second set. Previously both doors (in the second set) had a 1/3 probability, now one has been eliminated and the remaining has a 2/3 probability.
- valleyer 9y agoI've seen this explanation a million times, and I don't think it's very good. Here is one that sounds almost as plausible yet yields the opposite result: Divide the doors into two sets. The first set is the door you chose and the door that was opened; the second set is the remaining door. There is a 2/3 chance the correct door is in the first set and a 1/3 chance the correct door is in the second set. You are then told that one of the doors in the first set is not the correct door ... I find this line of thought much more intuitive: there is a 2/3 chance your original guess was wrong. If your original guess was wrong, the other door (the one that is not the one you chose and is not the one that was opened) is the right door. So there is a 2/3 chance the other door is the right door.
- danbruc 9y agoDivide the doors into two sets. The first set is the door you chose and the door that was opened; the second set is the remaining door. There is a 2/3 chance the correct door is in the first set and a 1/3 chance the correct door is in the second set. The error is assuming that the first set has a 2/3 probability of winning just because it contains 2 out of 3 doors while the way the set is constructed ensures that one of the doors, the door that is opened, never is the winning door. Including or excluding this door from a set must not change the probability you assign to this set containing the winning door, i.e. you can freely move this door between two sets or drop it altogether without affecting probabilities.
- deleted 9y ago
- ACow_Adonis 9y agoWhen I was but a wee...teenager...I was introduced to the monty-hall problem. It seemed so counter-intuitive, I can't say I wrote code to simulate it. No. Instead, I remember I got my dad and I said: "all right, here's what we're going to do. We're going to actually do this thing 100 times, and we're going to document the results on paper. Then I'm going to count up the results, cause this is bullshit!" Young mind was blown :P
- ramzyo 9y agoThis is a great story of intellectual curiosity and tenacity. Thank you for taking the time to share it!
- OscarCunningham 9y agoI think of it in terms of the flow of evidence. The host knows which door the car is behind. Therefore if he makes decisions based on that knowledge those decisions can give you information about the location of the car. If there is some action that he is more likely to perform when the car is behind door 1 than when it isn't, and he performs that action, then you should increase the probability you assign to the car being behind door 1. In particular if you've chosen door 2 then the host is more likely to reveal door 3 if the car is behind door 1 than if it isn't.
- gechr 9y agoIt's far easier to grasp when you consider that Monty opening one of the other 2 doors makes no difference to his offer (since he'll always open a door with a goat behind it anyway), i.e. he could also say "Do you want to stick with your door, or switch to both these other 2 doors?" without the unnecessary misdirection of opening the goat door beforehand.
- girvo 9y agoWow that made this finally click for me. Instead of two actions with the host in between, it’s just two actions. Thanks!
- tomalpha 9y agoThanks, I hadn’t thought of it quite that way. I hesitate to say “eureka!” but maybe, just maybe that might get me there :)
- yarg 9y agoDamn, that's way more intuitive than what I came up with.
- function_seven 9y agoI'll give it a shot :) Instead of reasoning about it as a contestant, you should actually play the game with someone, with you as Monty. Set up 3 playing cards. An ace and two jokers. Whatever. Have them choose a "door", then you reveal a joker and ask if they'd like to stay or switch. You'll quickly realize that they're forcing your hand most of the time.
- criddell 9y agoIt clicked with me when somebody explained it with playing cards but they used the entire deck. Spread out an entire deck of 52 cards, face down, on a table. Guess which card is the ace of spades. Monty then flips over to reveal 50 of the remaining 51 cards (none of which are the ace of spades) and you are given a choice to stick with your original guess or switch to the other face-down card.
- sethammons 9y agoSearch this page for my other comment. I'm curious if that helps (the part with C, G1, and G2).
- ehsankia 9y agoThere are many interesting variations of this, some that give the opposite behavior, if you ever want to trick someone who already knows the Monty Hall problem. https://www.youtube.com/watch?v=AB-FA75Tm1I https://www.youtube.com/watch?v=AB-FA75Tm1I
- jasode 9y agoSince a lot of university mathematicians, engineers, and physicists famously got the answer wrong, I've classified The Monty Hall Problem as more of an "English parsing" problem instead of a math problem. From wikipedia[1], the problem as stated: >"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 key phrase that everyone glosses over is: ", and the host, who knows what's behind the doors, opens another door, say No. 3, which has a goat." If it was reworded as "the host who knows what's behind the doors and _always_ opens the door with a goat and _never_ opens the door with the car", the mathematicians would have seen the 2/3rds probability. The original wording with the nonchalant "say" in the middle of ", opens another door, _say_ No. 3, which has a goat" makes it seems like there was no link between the host's knowledge of what's behind the door and the opening of door #3 and therefore random. Therefore, the 50/50 probability seemed to be the correct answer. [1] https://en.wikipedia.org/wiki/Monty_Hall_problem https://en.wikipedia.org/wiki/Monty_Hall_problem
- OscarCunningham 9y agoI agree that the wording of the problem is important, but I'm not sure if that's what was causing the mathematicians to get the wrong answer. I think I would have naturally assumed that the host was opening a door without the car in order to raise tension, and that he would therefore never open the door with the car. It would be interesting to survey mathematicians, but I don't think there's enough of them who haven't already heard the problem.
- Lazare 9y agoI'm not sure I agree. In particular: > If it was reworded as "the host who knows what's behind the doors and _always_ opens the door with a goat and _never_ opens the door with the car", the mathematicians would have seen the 2/3rds probability. There seems to be extensive examples of mathematicians encountering very clearly worded descriptions of the problem, but still failing to jump to the right answer. > The original wording with the nonchalant "say" in the middle of ", opens another door, say No. 3, which has a goat." makes it seems like there was no link between the host's knowledge of what's behind the door and the opening of door #3 and therefore random. Therefore the 50/50 probability seemed to be the correct answer. Yeah, but it's not 50/50. I think you're focusing on the wrong part there. The issue isn't the host's knowledge, it's the question of whether he always opens a door. If he always opens a door at random, and if in this particular run through he happens to open a door with a goat, then you will still double your odds if you switch. The host doesn't need to know what's behind the door for this to work! What does need to be the case is that the host always opens a door (or chooses whether or not to open a door for reasons other than his knowledge of what's behind them). In a hypothetical variant where Monty only opens a door and offers you the chance to switch if he knows you picked a car, you should never switch. In a variant where he only does so if he knows you didn't, you always should. :)
- placebo 9y agoI find that one can get a better intuitive grasp on many things when you take them to the extreme. In this case, suppose that instead of three doors, there are one hundred doors and behind 99 of them there are goats and behind 1 there's the car. After you select a door, say number 14. The host then tells you that it might be behind door number 14 but out of all the other doors he opens all but door 92, so you are left with two doors to choose from. I think the choice is quite obvious at this point. If not, then try a million doors...
- matt-attack 9y agoAs a high-schooler, this was my approach and it really locked in a strong understanding. You can really grok that with 1000 doors, for all intents and purposes, you basically had zero chance of getting it right on the first try, therefore you have basically a 100% chance of being right by switching.
- deleted 9y ago[deleted]
- hk__2 9y agoNote the `play` function can be reduced to these 3 lines : chosen = randint(1, 3) winning = randint(1, 3) return (chosen != winning) == switch The only way to win if we don’t switch is to have chosen the winning door (switch==false, chosen==winning); the only way to win if we switch is not to have chosen the winning door (switch==true, chosen!=winning).
- thisacctforreal 9y agoif (chosen == winning && !switch): return true if (chosen != winning && switch): return true return false Is a longer but easier version to read.
- hk__2 9y agoFYI Python uses `and`, not `&&`.
- modernerd 9y ago“Pigeons repeatedly exposed to the problem show that they rapidly learn always to switch, unlike humans.” — https://en.wikipedia.org/wiki/Monty_Hall_problem#Sources_of_confusion https://en.wikipedia.org/wiki/Monty_Hall_problem#Sources_of_...
- loup-vaillant 9y agoI've done a more complete analysis here, with a simulation program: http://loup-vaillant.fr/tutorials/monty-hall http://loup-vaillant.fr/tutorials/monty-hall Whether you should switch or not is highly dependent on what you know of the host. In the classical problem, you should switch. But there are hosts with which one should never switch.
- ken666 9y agoFor those who speak spanish: http://www.investigacionyciencia.es/blogs/matematicas/33/posts/el-programa-que-convenci-a-erds-11982 http://www.investigacionyciencia.es/blogs/matematicas/33/pos...