蒙蒂霍尔问题
I’ve been hearing about the Monty Hall problem for years and its never quite made sense to me, so I decided to program up a quick simulation.
多年来,我一直在听说有关Monty Hall的问题 ,但对我而言从来没有这么有意义,所以我决定编写一个快速仿真程序。
In the Monty Hall problem, there is a car behind one of three doors. There are goats behind the other two doors. The contestant picks one of the three doors. Monty Hall (the game show host) then reveals that one of the two unchosen doors has a goat behind it. The question is whether the constestant should change the door they picked or keep their choice.
在蒙蒂·霍尔(Monty Hall)问题中,三个门之一后方有一辆汽车。 另外两扇门后面有山羊。 参赛者选择三个门之一。 然后,蒙蒂·霍尔(游戏节目主持人)揭示了两个未选择的门中的一扇后面有一只山羊。 问题是,野兽应该改变他们选择的门还是保持选择。
My first intuition was that it doesn’t matter whether the contestant changes their choice because its equally probable that the car is behind either of the two unopened doors, but I’ve been told this is incorrect! Instead, the contestant is more likely to win the car if they change their choice.
我的第一个直觉是,参赛者是否更改选择并不重要,因为赛车同样有可能在两个未打开的门中的任何一个后面,但是我被告知这是错误的! 相反,如果他们改变选择,则参赛者更有可能赢得赛车。
How can this be? Well, I decided to create a simple simulation of the Monty Hall problem in order to prove to myself that there really is an advantage to changing the chosen door and (hopefully) gain an intuition into how this works.
怎么会这样? 好吧,我决定为Monty Hall问题创建一个简单的模拟,以便向自己证明改变所选门的确有好处,并且(希望)对它的工作原理有所了解。
Below I’ve written my little simulation. A jupyter notebook with this code is available on my github.
下面,我写了我的小模拟。 我的github上有一个带有此代码的jupyter笔记本。
|
Here I plot the results
在这里我绘制结果
|
Probability of choosing correctly if change choice: 0.67 Probability of choosing correctly if do not change choice: 0.33 Probability of difference arising from chance: 0.00000
Probability of choosing correctly if change choice: 0.67 Probability of choosing correctly if do not change choice: 0.33 Probability of difference arising from chance: 0.00000
Clearly, the contestant should change their choice!
显然,参赛者应该改变选择!
So now, just to make sure I am not crazy, I decided to simulate the Monty Hall problem with the contestant choosing what door to open after Monty Hall opens a door with a goat.
所以现在,为了确保我不发疯,我决定模拟模拟Monty Hall的问题,让参赛者选择在Monty Hall用山羊打开一扇门之后要打开的门。
|
|
Now, there is clearly no difference between whether the contestant changes their choice or not.
现在,参赛者是否更改选择之间显然没有区别。
翻译自: https://www.pybloggers.com/2016/12/simulating-the-monty-hall-problem/
蒙蒂霍尔问题