返回题库

去钓鱼

Gone Fishing

专题
Probability / 概率
难度
L3

题目详情

一只熊想要从河里捕获 33 鱼。钓到 3 条鱼后,熊就离开了。当鱼来时,他有 12\frac12 的机会抓住它。第五条鱼没被钓到的概率是多少?

A bear wants to catch 33 fish from a river. Upon catching 3 fish the bear leaves. When a fish comes, there is a 12\frac12 chance he'll catch it. What is the probability that the fifth fish will not be caught?

解析

只有当熊从第一条 44 中捕获 001122 鱼时,它才会钓鱼第五条鱼。这是 p=12p = \frac12 的二项式: P(F)=((40)(12)4+(41)(12)4+(42)(12)4)=1116P(F) = ({4\choose0}(\frac12)^4 + {4\choose1}(\frac12)^4 + {4\choose2}(\frac12)^4) = \frac{11}{16} 我们知道,当熊钓鱼时,有一半的机会会钓到第五条鱼。这对应于概率 111612\frac{11}{16}*\frac{1}{2}。然而,我们正在计算第五条鱼被 notnot 捕获的概率。第五条鱼未被捕获的概率只是该事件的补充,因此我们得到: 1(111612)=21321 - (\frac{11}{16}\cdot\frac12) = \boxed{\frac{21}{32}}

import random

catch_fish = lambda: True if random.randint(1, 2) == 1 else False

num_fifth_fish_caught = 0
num_iters = 100_000
for i in range(num_iters):

    total_fish = 0
    for fish in range(4):

        if catch_fish():
            total_fish += 1

    if total_fish < 3:
        if catch_fish():
            num_fifth_fish_caught += 1

print((num_iters - num_fifth_fish_caught)/num_iters)

Original Explanation

The bear will only be fishing for the fifth fish when it has caught 00, 11, or 22 fish out of the first 44. This is binomial with p=12p = \frac12: P(F)=((40)(12)4+(41)(12)4+(42)(12)4)=1116P(F) = ({4\choose0}(\frac12)^4 + {4\choose1}(\frac12)^4 + {4\choose2}(\frac12)^4) = \frac{11}{16}

We know the bear will catch the fifth fish half the time when it is fishing for it. This corresponds to the probability 111612\frac{11}{16}*\frac{1}{2}. However, we are looking to compute the probability that the fifth fish is notnot caught. The probability the fifth fish is not caught is simply the complement of this event and so we get: 1(111612)=21321 - (\frac{11}{16}\cdot\frac12) = \boxed{\frac{21}{32}}

import random

catch_fish = lambda: True if random.randint(1, 2) == 1 else False

num_fifth_fish_caught = 0
num_iters = 100_000
for i in range(num_iters):

    total_fish = 0
    for fish in range(4):

        if catch_fish():
            total_fish += 1

    if total_fish < 3:
        if catch_fish():
            num_fifth_fish_caught += 1

print((num_iters - num_fifth_fish_caught)/num_iters)