组合学、概率、骰子
我的一个朋友问:如果我有两个骰子,我把它们都扔了,(两个骰子的数字)最常见的和是多少?
我写了一个小脚本:
from random import randrange
d = dict((i, 0) for i in range(2, 13))
for i in xrange(100000):
d[randrange(1, 7) + randrange(1, 7)] += 1
print d
哪个打印:
2: 2770,
3: 5547,
4: 8379,
5: 10972,
6: 13911,
7: 16610,
8: 14010,
9: 11138,
10: 8372,
11: 5545,
12: 2746
我的问题是,为什么 11 比 12 更频繁?在这两种情况下,只有一种方法(或两种,如果你也反向计数)如何获得这样的总和(5 + 6, 6 + 6),所以我期望相同的概率..?
A friend of mine asked: if I have two dice and I throw both of them, what is the most frequent sum (of the two dice' numbers)?
I wrote a small script:
from random import randrange
d = dict((i, 0) for i in range(2, 13))
for i in xrange(100000):
d[randrange(1, 7) + randrange(1, 7)] += 1
print d
Which prints:
2: 2770,
3: 5547,
4: 8379,
5: 10972,
6: 13911,
7: 16610,
8: 14010,
9: 11138,
10: 8372,
11: 5545,
12: 2746
The question I have, why is 11 more frequent than 12? In both cases there is only one way (or two, if you count reverse too) how to get such sum (5 + 6, 6 + 6), so I expected the same probability..?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
有两种方法。如果骰子被命名为 A 和 B:
12 = 一种方式:A=6,B=6
11 = 两种方式:A=5,B=6 和 A=6,B=5。
There are two ways. If the dice are named A and B:
12 = one way: A=6, B=6
11 = two ways: A=5, B=6 and A=6, B=5.
首先,这个问题假设你的任意尝试给出了权威的结果。事实并非如此;结果是纯随机的,并且仅在一定程度上可靠。但在这种特殊情况下,这些数字实际上很好地反映了真实的比例。
也就是说,有两种方法可以获得 11:5(第一个骰子)+ 6(第二个骰子)和 6(第一个骰子)+ 5(第二个骰子),但只有一种方法可以获得 12:6(第一个骰子)+ 6(第二个模具)。
First of all, this question assumes that your arbitrary try gives an authoritative result. It doesn’t; the result is pure random and only reliable up to a degree. But in this particular case, the numbers actually reflect the real proportions nicely.
That said, there are two ways to get 11: 5 (first die) + 6 (second die) and 6 (first die) + 5 (second die) but only one way to get 12: 6 (first die) + 6 (second die).
根据您的经验测试,最常遇到的总和是 7。
现在,具体回答您的问题:
查看概率了解更多信息。
The most frequently met sum is 7, as suggested by your empirical test.
Now, to answer your questions specifically:
Check out Probability for more info.
对于 11,有 5 + 6;对于 12,有 6 + 5,只有 6 + 6。
您可以通过 2 和 3 观察到同样的情况。
For 11 there is 5 + 6 and 6 + 5 for 12 there is only 6 + 6.
You can observe the same thing with 2 and 3.