返回题库

均匀商数

Uniform Quotient

专题
Probability / 概率
难度
L4

题目详情

如果aabb[0,1][0, 1]中是一致的,那么a/ba/b[1,3][1,3]中的概率是多少?

If aa and bb are uniform in [0,1][0, 1] what is the probability that a/ba/b is in [1,3][1,3]?

解析

如果 a/ba/b 的商位于 [1,3][1,3] 中,则 bb 至少为 a/3a/3,至多为 aa。因此,我们可以将概率重写为: P(a3<b<a)P(\frac{a}3 < b < a) 我们可以将 aa 的任何值代入其中以求出一般条件概率: P(a3<b<aa)=aa3=2a3P(\frac{a}3 < b < a | a) = a - \frac{a}3 = \frac{2a}3 利用总概率定律,我们可以将所有条件概率相加来求出一般概率: P(a3<b<a)=01P(a3<b<aa)da=012a3da=13P(\frac{a}3 < b < a) = \int_0^1 P(\frac{a}3 < b < a | a) da = \int_0^1 \frac{2a}3 da = \boxed{\frac13}

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)

Original Explanation

If the quotient of a/ba/b lies in [1,3][1,3], bb is at least a/3a/3 and at most aa. Thus, we can re-write our probability to: P(a3<b<a)P(\frac{a}3 < b < a) We can substitute any value of aa into this to find the general conditional probability: P(a3<b<aa)=aa3=2a3P(\frac{a}3 < b < a | a) = a - \frac{a}3 = \frac{2a}3 Using the law of total probability, we can sum all of the conditional probabilities to find the general probability: P(a3<b<a)=01P(a3<b<aa)da=012a3da=13P(\frac{a}3 < b < a) = \int_0^1 P(\frac{a}3 < b < a | a) da = \int_0^1 \frac{2a}3 da = \boxed{\frac13}

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)