恰为 6
Exactly 6
题目详情
如果我掷骰子 36 次,每个数字恰好出现 6 次的概率是多少?
If I roll a dice 36 times, what is the probability that each number appears exactly 6 times?
解析
为了解决这个问题,我们可以利用多项式定理。该定理指出,对于 试验的实验, 可能的结果和 期望的结果对应于每个可能的结果,可能的实验结果的数量由以下公式给出:
我们知道骰子中出现任何面的概率是 ,并且我们掷骰子 36 次。因此,我们给出了如下的解决方案:
这是一个验证我们解决方案的 python 程序:
import random
from typing import Callable
from collections import Counter
roll_dice: Callable[[None], int] = lambda: random.randrange(1, 7, 1)
def simulation() -> bool:
# Roll the dice 36 times
rolls = [roll_dice() for _ in range(36)]
# Count how many times each number appeared
counts = Counter(rolls)
# Check that each number appeared 6 times
return len(counts.keys()) == 6 and all([count == 6 for count in counts.values()])
iterations = 100_000
probability = sum([simulation() for _ in range(iterations)]) / iterations
print(f"The probability that each number appears exactly six times is: {probability}")Original Explanation
To solve this question, we can leverage the multinomial theorem. This theorem states that for an experiment with trials, with possible results and desired outcomes corresponding to each of the possible results, the number of possible experimental outcomes is given by the following formula:
We know that the probability of any face from the dice showing up is and that we are rolling the dice 36 times. Therefore, we have the solution given below:
Here is a python program validating our solution:
import random
from typing import Callable
from collections import Counter
roll_dice: Callable[[None], int] = lambda: random.randrange(1, 7, 1)
def simulation() -> bool:
# Roll the dice 36 times
rolls = [roll_dice() for _ in range(36)]
# Count how many times each number appeared
counts = Counter(rolls)
# Check that each number appeared 6 times
return len(counts.keys()) == 6 and all([count == 6 for count in counts.values()])
iterations = 100_000
probability = sum([simulation() for _ in range(iterations)]) / iterations
print(f"The probability that each number appears exactly six times is: {probability}")