组合学、概率、骰子

发布于 2024-08-26 10:49:52 字数 491 浏览 8 评论 0原文

我的一个朋友问:如果我有两个骰子,我把它们都扔了,(两个骰子的数字)最常见的和是多少?

我写了一个小脚本:

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

萌逼全场 2024-09-02 10:49:52

在这两种情况下只有一种方法
(或者两个,如果你也反向数的话)

有两种方法。如果骰子被命名为 A 和 B:

12 = 一种方式:A=6,B=6

11 = 两种方式:A=5,B=6 和 A=6,B=5。

In both cases there is only one way
(or two, if you count reverse too)

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.

掐死时间 2024-09-02 10:49:52

我的问题是,为什么 11 比 12 出现的频率更高?

首先,这个问题假设你的任意尝试给出了权威的结果。事实并非如此;结果是纯随机的,并且仅在一定程度上可靠。但在这种特殊情况下,这些数字实际上很好地反映了真实的比例。

也就是说,有两种方法可以获得 11:5(第一个骰子)+ 6(第二个骰子)和 6(第一个骰子)+ 5(第二个骰子),但只有一种方法可以获得 12:6(第一个骰子)+ 6(第二个模具)。

The question I have, why is 11 more frequent than 12?

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).

尤怨 2024-09-02 10:49:52

根据您的经验测试,最常遇到的总和是 7。

现在,具体回答您的问题:

  • 11 比 12 出现的频率更高,因为通过滚动 6,6 可以得到 12,但是通过 5,6 或 6,5 可以得到 11,这是概率的两倍。
  • 根据经典概率论,事件发生的概率等于(触发它的有益简单事件数)/(所有可能事件数)。因此,使用这个简单的公式得出,为了得到 7,您需要滚动以下组合之一:(1,6)、(2,5)、(3,4)、(4,3)、(5 ,2), (6,1),总共有 6x6=36 个事件。得到 7 的几率是 P = 6/36 = 1/6,这是尽可能高的。

查看概率了解更多信息。

The most frequently met sum is 7, as suggested by your empirical test.

Now, to answer your questions specifically:

  • 11 is more frequent than 12 because you get 12 by rolling 6,6, but you can get 11 by 5,6 or 6,5, which is double the probability.
  • Based on classic probability theory, the probability of an event occurring is equal to (number-of-beneficial-simple-events-that-trigger-it)/(number-of-all-possible-events). So using this simple formula yields that in order to get a 7, you need to roll one of the following combinations: (1,6), (2,5), (3,4), (4,3), (5,2), (6,1), and you have 6x6=36 events all together. The chance of getting a 7 is P = 6/36 = 1/6, which is as high as it gets.

Check out Probability for more info.

永言不败 2024-09-02 10:49:52

对于 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文