Combinatorics, probability, dice
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,开发者_StackOverflow社区 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..?
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.
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).
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.
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.
精彩评论