我们将三个骰子中最小值的值称为 X。使用生存函数求期望:
E[X]=k=1∑100P(X≥k)
X 至少为 k 的概率是
P(X≥k)=1003(100−k+1)3.
因此
E[X]=10031003+1003993+1003983+⋯+100313=10031(1003+993+983+⋯+13).
利用立方和公式
13+23+⋯+1003=(1+2+⋯+100)2,
且
k=1∑100k=100⋅21+100=5050,
所以
E[X]=100350502=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)
Original Explanation
Let's call the value of the minimum of the three die X. Using expectation by summation of survival we get:
E[X]=k=1∑100P(X≥k)
The probability that X is at least k is 1003(100−k+1)3 so,
E[X]=10031003+1003993+1003983+⋯+100313
=10031(1003+993+983+⋯+13)
The sum of cubes can also be written from 1 to n can be rewritten to the square of the sum from 1 to n thus,
E[X]=1003(1+2+3+⋯+100)2
⟹k=1∑100k=100⋅21+100=5050
⟹E[X]=100350502=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)