# Hacker News

## Show HN: Understanding the Monty Hall paradox through code: 55

If you phrase it adversarially it makes more sense... 2/3 of the time you select a goat and force Monty to reveal the other goat. For those 2/3, you're guaranteed to get a car by switching. The remaining third you get a goat.

If you take the "stay" strategy... 1/3 you hit the car and keep it. 2/3 you hit a goat and keep it.

In summary... "switch" is 2/3 car, "stay" is 2/3 goat.

In these times you should choose "stay" and hope to get a goat so you can turn grass into food. Cars are overrated. - drewm1980 2 months ago

The easiest explanation I've ever heard and which immediately made me understand it was the following:

Instead of 3 doors, imagine there are 100. 99 of which have a goat and only one of which has a price behind it. Now blindly choose a door and the host opens 98 of the other doors which have a goat behind it. Would you switch your door now, given the choice?

It's easy to see that your probability of choosing a "wrong" door when you had 100 doors to choose from was much higher than choosing the right door when you only have two doors to choose from.

This method of thinking, i.e. increasing or decreasing the problem space by some orders of magintude has helped me a lot in thinking about problems and their solutions in general. - andischo 2 months ago

One thing that intrigued me about this puzzle is wondering what mental model for probability would make solving it intuitive? The one that works for me was thinking about it in terms of information:

Because Monty can never choose the door you first picked he can't give you any new information about that door. So when he reveals which of the remaining doors has a goat, he is only giving us new information about those remaining doors. That information reduces the odds on the remaining doors and that is why you should always switch. - aszs 2 months ago

The main thing that seems to cause the paradox is a lack of specificity around the door opening mechanism. If you make it clear that Monty only opens a door that will definitely be empty, I find that most commentators will agree that Marilyn is correct, you should switch. - lordnacho 2 months ago

Monty Hall himself wrote to the Harvard C.S. Professor Lawrence Denenberg questioning the counter-intuitive logic:

> https://stats.stackexchange.com/questions/373/the-monty-hall...

____

The topic of the counter-intuitive nature of probability reminds of Newton's letter to Pepys - "In 1693, Isaac Newton answered a query from Samuel Pepys about a problem involving dice. Newton’s analysis is discussed and attention is drawn to an error he made."

Here is the classic Newton-Pepys Problem http://www.datagenetics.com/blog/february12014/

Here is the Newton-Pepys problem explained by Professor Joe Blitzstein in the Harvard class Stats110: https://www.youtube.com/watch?v=P7NE4WF8j-Q&feature=youtu.be....

Here is further discussion about the logical error Newton made in his solution: http://arxiv.org/pdf/math/0701089.pdf - dpflan 2 months ago

It seems to me that a lot of what trips people up is that they don't realize that the host specifically opens a door which they know does not to contain a car (as opposed to selecting the door to open randomly).

Therefore, it seems to me that many people fall for it not so much because they misunderstand the probability but because the rules of the game are designed to be misleading. - harimau777 2 months ago

For a more prosaic use of code to help people understand, I once wrote a quick simulation to help get it into the intuitions of my students: https://paul-gowder.com/montyhall/ - paultopia 2 months ago

I finally understood it!

I always wondered why it's not 50/50 if I enter the room late. How can a past event that now seems irrelevant change the odds.

Basically you watch Monte jump around and see which doors he avoids because they have prices. Now you can't make that observation about your own door because he'd never touch it anyways and he jumps just once but sometimes skipping a door if his random hits the price. The fact that it's just 3 doors so just one is left makes it even more quirky, but doesn't change much.

So you know the other door is a door monty pontentialy avoided not to reveal the price.You don't have that information about your door. - anotheryou 2 months ago

Much more complete discussion of the problem, with strategy variants and code: http://loup-vaillant.fr/tutorials/monty-hall

Author is also a HNer: https://news.ycombinator.com/user?id=loup-vaillant - bmn__ 2 months ago

For this and other probability "paradoxes" explained through code, check out this great notebook: https://nbviewer.jupyter.org/github/norvig/pytudes/blob/mast... - gugagore 2 months ago

Why do explanations of this problem never mention conditional probability, on which the explanation is based?

There are dozens of videos explaining conditional probability on youtube, but basically, the taking away of a door gives us additional information about the state of the system. It is counter-intuitive, but it's not a mystery.

This principle is used everywhere to optimize real-world problems. - oceanghost 2 months ago

There's a Kevin Spacey movie scene on this: https://www.youtube.com/watch?v=cXqDIFUB7YU - textread 2 months ago

Michael Stevens of Vsauce does a fantastic job explaining why this works: https://youtu.be/TVq2ivVpZgQ - davidmurdoch 2 months ago

for me it clicked when i realized he will only open the bad door which you have not chosen. Even if you chose the bad door he will never open that one to show you. He’ll always open the other - thecopy 2 months ago

The simplest solution is you Always switch as it meant 2/3 instead of 1/3 winning chance. the door opening earlier or (clearer and easier to understand) later is just to help you to check your 2/3 pool. - ngcc_hk 2 months ago

Github supports the IPython notebook format.

I much rather prefer that for literate programming. - 29athrowaway 2 months ago