Created
May 13, 2016 05:43
-
-
Save badbye/544af518c736ae414a8c691f4e3f3ff1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 最后一个问题当时给我的印象特别深,让人不由得赞叹怎么可以构造出这么离奇却又合理的概率命题。 | |
# 想象现在有两个盒子,两个盒子里各有整数,我们只知道它们不相同,没有其它任何进一步的信息。 | |
# 现在游戏主办方允许我们打开一个箱子,然后猜另一个里面的数字比我们看到这个数大还是小。初看之 | |
# 下,似乎没有任何办法帮我们来确知另一个盒子里究竟是个啥。但现在,只要你有一个随机数发生器, | |
# 你就可以改变命运。不妨假设我们有一个均匀随机转盘,转盘转到的角度服从上的均匀分布。我们按如 | |
# 下规则猜测:从两个盒子中随便挑一个数字,然后转动转盘。如果比我们猜的这个数大,就猜大,反之 | |
# 则猜小。 | |
# | |
# 作者:猪月 | |
# 链接:https://www.zhihu.com/question/41408857/answer/90886492 | |
# 来源:知乎 | |
# 著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。 | |
n = 100000 | |
res = numeric(n) | |
for (i in seq(1, n)) { | |
nums2choice = rt(2, 5) | |
choice = sample(1:2, 1) | |
theta = runif(1, 0, 2*pi) | |
rand = 1 / tan(theta / 2) | |
res[i] = (nums2choice[setdiff(1:2, choice)] > nums2choice[choice]) == (rand > nums2choice[choice]) | |
} | |
mean(res) # significant larger than 0.5 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment