
Monty Hall Problem Simulation - icepy
https://github.com/mycask/monty-hall-sim
======
jasode
Since 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)

~~~
Lazare
I'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. :)

~~~
jasode
_> , 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. _

Yes, I agree.

 _> The host doesn't need to know what's behind the door for this to work!_

The host has to know it and always open the goat door to prevent
mathematicians from making a _repeated simulation_ in their minds where the
host _sometimes opens a door with a car_ behind it.

That would be over-reading and misinterpreting the MH wording but that's why
the problem is so enduring -- it uses clever text to misdirect a lot of smart
people _away_ from the correct 2/3rds answer.

~~~
yen223
Weirdly enough, in the scenario where the host doesn't know which door has the
goat and just happens to open the right door, your odds of winning the car if
you switch actually does go back to 50-50.

Edit: I made a quick IPython notebook to demonstrate this:
[https://github.com/yen223/monty_fall/blob/master/Monty%20Hal...](https://github.com/yen223/monty_fall/blob/master/Monty%20Hall%20vs%20Monty%20Fall.ipynb)

~~~
mannykannot
In your program, you have to classify all cases where the host picks the prize
on his second selection as 'passed', and put them aside. This affects the
result, as in all those cases the subject had picked one of the wrong boxes,
so you have biased the cases you actually consider towards those where the
subject originally picked the right box.

------
placebo
I 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
As 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.

------
tomalpha
This 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.

~~~
gechr
It'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.

~~~
tomalpha
Thanks, I hadn’t thought of it quite that way. I hesitate to say “eureka!” but
maybe, just maybe that might get me there :)

------
modernerd
“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_...](https://en.wikipedia.org/wiki/Monty_Hall_problem#Sources_of_confusion)

------
ehsankia
There 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)

------
hk__2
Note 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

        if (chosen == winning && !switch):
            return true
        if (chosen != winning && switch):
            return true
        return false
    

Is a longer but easier version to read.

~~~
hk__2
FYI Python uses `and`, not `&&`.

------
loup-vaillant
I'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
For those who speak spanish:
[http://www.investigacionyciencia.es/blogs/matematicas/33/pos...](http://www.investigacionyciencia.es/blogs/matematicas/33/posts/el-
programa-que-convenci-a-erds-11982)

