返回题库

三个骰子的最小值

3 Die Minimum

专题
Statistics / 统计
难度
L9

题目详情

假设你掷出三个 100 面骰子。最低滚动的预期值是多少?

英文原题

Suppose you roll three fair 100-sided die. What is the expected value of the lowest roll?

解析

我们将三个骰子中最小值的值称为 XX。使用生存函数求期望:

E[X]=∑k=1100P(X≥k)E[X] = \sum_{k=1}^{100} P(X \geq k)

XX 至少为 kk 的概率是

P(X≥k)=(100−k+1)31003.P(X\ge k)=\frac{(100-k+1)^3}{100^3}.

因此

E[X]=10031003+9931003+9831003+⋯+131003=11003(1003+993+983+⋯+13).E[X] = \frac{100^3}{100^3} + \frac{99^3}{100^3} + \frac{98^3}{100^3} + \dots + \frac{1^3}{100^3} = \frac{1}{100^3}\left(100^3+99^3+98^3+\dots+1^3\right).

利用立方和公式

13+23+⋯+1003=(1+2+⋯+100)2,1^3+2^3+\cdots+100^3=(1+2+\cdots+100)^2,

且

∑k=1100k=100⋅1+1002=5050,\sum_{k=1}^{100}k=100\cdot\frac{1+100}{2}=5050,

所以

E[X]=505021003=25.5025.E[X]=\frac{5050^2}{100^3}=\boxed{25.5025}.
import random

roll_dice = lambda: random.randint(1, 100)

mins = []
num_iters = 1_000_000
for i in range(num_iters):

    d1 = roll_dice()
    d2 = roll_dice()
    d3 = roll_dice()

    mins.append(min(d1, d2, d3))

print(sum(mins) / num_iters)

英文解析

Let's call the value of the minimum of the three die XX. Using expectation by summation of survival we get:

E[X]=∑k=1100P(X≥k)E[X] = \sum_{k=1}^{100}P(X \geq k)

The probability that XX is at least kk is (100−k+1)31003\frac{(100-k+1)^3}{100^3} so,

E[X]=10031003+9931003+9831003+⋯+131003E[X] = \frac{100^3}{100^3} + \frac{99^3}{100^3} + \frac{98^3}{100^3} + \dots + \frac{1^3}{100^3} =11003(1003+993+983+⋯+13)= \frac1{100^3}({100^3} + {99^3} + {98^3} + \dots + {1^3})

The sum of cubes can also be written from 11 to nn can be rewritten to the square of the sum from 11 to nn thus,

E[X]=(1+2+3+⋯+100)21003E[X] = \frac{(1 + 2 + 3 + \dots+ 100)^2}{100^3} ⟹∑k=1100k=100⋅1+1002=5050\Longrightarrow \sum_{k=1}^{100}k = 100\cdot\frac{1+100}{2} = 5050 ⟹E[X]=505021003=25.5025\Longrightarrow E[X] = \frac{5050^2}{100^3} = \boxed{25.5025}
import random

roll_dice = lambda: random.randint(1, 100)

mins = []
num_iters = 1_000_000
for i in range(num_iters):

    d1 = roll_dice()
    d2 = roll_dice()
    d3 = roll_dice()

    mins.append(min(d1, d2, d3))

print(sum(mins) / num_iters)