返回题库

恰为 6

Exactly 6

专题
Probability / 概率
难度
L3

题目详情

如果我掷骰子 36 次,每个数字恰好出现 6 次的概率是多少?

If I roll a dice 36 times, what is the probability that each number appears exactly 6 times?

解析

为了解决这个问题,我们可以利用多项式定理。该定理指出,对于 nn 试验的实验,kk 可能的结果和 x1,...,xkx_1, ..., x_k 期望的结果对应于每个可能的结果,可能的实验结果的数量由以下公式给出: (nx1,..,xk)=n!x1,...,xk{n \choose x_1, .., x_k} = \frac{n!}{x_1, ..., x_k}

我们知道骰子中出现任何面的概率是 1/61/6,并且我们掷骰子 36 次。因此,我们给出了如下的解决方案:

(366,6,6,6,6,6)×(1/6)36=36!6!6(16)360.00025{36 \choose {6, 6, 6, 6, 6, 6}} \times (1/6)^{36} = \frac{36!}{6!^6}(\frac{1}{6})^{36} \approx 0.00025

这是一个验证我们解决方案的 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 nn trials, with kk possible results and x1,...,xkx_1, ..., x_k desired outcomes corresponding to each of the possible results, the number of possible experimental outcomes is given by the following formula: (nx1,..,xk)=n!x1,...,xk{n \choose x_1, .., x_k} = \frac{n!}{x_1, ..., x_k}

We know that the probability of any face from the dice showing up is 1/61/6 and that we are rolling the dice 36 times. Therefore, we have the solution given below:

(366,6,6,6,6,6)×(1/6)36=36!6!6(16)360.00025{36 \choose {6, 6, 6, 6, 6, 6}} \times (1/6)^{36} = \frac{36!}{6!^6}(\frac{1}{6})^{36} \approx 0.00025

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}")