周末和小妞还有她的室友,及室友的男友一起去看了《21》。我是第二次看了,还是好看,男女主角超级有型就不说了,故事情节,画面,音乐,都可圈可点。第二遍看给我留下深刻映象的是MIT的那堂数学课,关于逻辑的,那个三扇门的游戏。
这个游戏的原型是Monty Hall Problem。我在回Pittsburgh的路上一直在思考这里的概率问题,实在是想不通,导演也没有仔细解释,和couting cards的细节一样,让观众去揣摩,要装的高深(其实导演自己也搞不明白
)!在网上搜了一通以后,发现有不少人跟我有同样的问题。仔细研究了Wikipedia的那篇文章,豁然开朗,总结出两点:
1. 弄清楚游戏的规则
2. 不要想当然
这里游戏规则的关键是“Host必须选择打开一扇有山羊的门”。人类思维上潜移默化的“想当然”在这个问题上愚弄了很多诺贝尔奖获得者和数学家。还有很多关于这个问题的细节和讨论,请参见Wikipedia (国内解封了吧),强烈推荐!
实践出真知,我写了段代码模拟了一下这个游戏,“想当然”的确是不对的
public static void main(String[] args) {
Random rand = new Random();
int car = 0;
int scale = 10000;
for (int i = 0; i < scale; i++) {
// t means the door # which has the car
int t = rand.nextInt(3);
// assume the player always pick door 1, it actually doesn't matter
// so, the host has to reveal a goat behind door 2 or door3
int theThirdDoor;
if (t == 1) {
// reveal door3, the third door is door 2
theThirdDoor = 1;
} else {
// reveal door2, the third door is door 3
theThirdDoor = 2;
}
// now, player switch, let's see the result
if (t == theThirdDoor) {
car++;
}
}
System.out.println((double)car / (double)scale);
}
请不要说我的代码很傻很天真。有兴趣的跑一下看看,结果确实是0.6,不是0.3。
在研究这个问题的过程中,发现了一本书《The Power of Logical Thinking》,打算有空拜读一下。谁能说说“思维”和“思路”的区别?我曾经想过要“感性的思维,理性的思路”,不懂如何解释。今天突然觉得应该是“Think Logically, Behave Emotionally”,但是我依然不懂如何解释。很模糊~
We are counting, not gambling...
You are grambling, not counting!
心情: 一般