均匀商数
Uniform Quotient
题目详情
如果和在中是一致的,那么在中的概率是多少?
英文原题
If and are uniform in what is the probability that is in ?
解析
如果 的商位于 中,则 至少为 ,至多为 。因此,我们可以将概率重写为:
我们可以将 的任何值代入其中以求出一般条件概率:
利用总概率定律,我们可以将所有条件概率相加来求出一般概率:
import random
quotients = []
num_iters = 10_000
for i in range(num_iters):
a = random.uniform(0, 1)
b = random.uniform(0, 1)
quotients.append(a/b)
in_bounds = len([q for q in quotients if q >= 1 and q <= 3])
#expecting answer close to 1/3
print(in_bounds/num_iters)英文解析
If the quotient of lies in , is at least and at most . Thus, we can re-write our probability to:
We can substitute any value of into this to find the general conditional probability:
Using the law of total probability, we can sum all of the conditional probabilities to find the general probability:
import random
quotients = []
num_iters = 10_000
for i in range(num_iters):
a = random.uniform(0, 1)
b = random.uniform(0, 1)
quotients.append(a/b)
in_bounds = len([q for q in quotients if q >= 1 and q <= 3])
#expecting answer close to 1/3
print(in_bounds/num_iters)