В первой урне 5 белых и 3 чёрных шара, во второй — 2 белых и 6 чёрных. Из первой урны наугад вынимают два шара и, не глядя на них, перекладывают во вторую. После этого из второй урны наугад достают один шар, и он оказывается белым.
Найдите вероятность того, что оба переложенных шара были белыми.
Шары различаются только цветом: любая пара шаров при перекладывании равновозможна, и каждый из десяти шаров второй урны равновозможен при извлечении. Ответ округлите до четырёх знаков после запятой.
The first urn contains 5 white balls and 3 black balls; the second contains 2 white balls and 6 black balls. Two balls are drawn uniformly at random from the first urn and transferred to the second without observing their colors. A ball is then drawn uniformly at random from the second urn, and it is white.
Find the probability that both transferred balls were white.
The balls differ only in color: every pair of balls is equally likely to be transferred, and each of the ten balls in the second urn is equally likely to be drawn. Round your answer to four decimal places.
Подсказка / Hint
Гипотезы — сколько белых уехало во вторую урну; их три. Априорные вероятности берутся счётом пар в первой урне, знаменатель собирается формулой полной вероятности, и только потом условие разворачивается.
Use three hypotheses, according to the number of white balls transferred to the second urn. Obtain their prior probabilities by counting pairs in the first urn, compute the denominator using the law of total probability, and only then reverse the conditioning.
Решение / Solution
Гипотезы. $H_2$ — переложены два белых, $H_1$ — один белый и один чёрный, $H_0$ — два чёрных. Других вариантов нет, и они несовместны.
Априорные вероятности — счёт пар в первой урне. Всего пар $\binom{8}{2} = 28$:
$$\P(H_2) = \frac{\binom52}{28} = \frac{10}{28}, \qquad \P(H_1) = \frac{5 \cdot 3}{28} = \frac{15}{28}, \qquad \P(H_0) = \frac{\binom32}{28} = \frac{3}{28}$$Правдоподобия. После перекладывания во второй урне 10 шаров, и белых в ней ровно столько, сколько было своих (2), плюс сколько приехало:
$$\P(W \mid H_2) = \frac{4}{10}, \qquad \P(W \mid H_1) = \frac{3}{10}, \qquad \P(W \mid H_0) = \frac{2}{10}$$Знаменатель — формула полной вероятности.
$$\P(W) = \frac{10}{28}\cdot\frac{4}{10} + \frac{15}{28}\cdot\frac{3}{10} + \frac{3}{28}\cdot\frac{2}{10} = \frac{40 + 45 + 6}{280} = \frac{91}{280} = \frac{13}{40} = 0.325$$Байес — разворот условия.
$$\P(H_2 \mid W) = \frac{\P(W \mid H_2)\,\P(H_2)}{\P(W)} = \frac{40/280}{91/280} = \frac{40}{91} \approx 0.4396$$До извлечения гипотеза «оба белых» стоила $\frac{10}{28} \approx 0.3571$. Белый шар на выходе — свидетельство в её пользу, значит апостериорная вероятность обязана вырасти, а не упасть: $0.4396 > 0.3571$ ✓. Заодно $\P(W) = 0.325$ зажата между крайними правдоподобиями $0.2$ и $0.4$ — иначе где-то потерян множитель.
Априорные вероятности гипотез — чистая комбинаторика: $\binom52 = 10$, $5 \cdot 3 = 15$ и $\binom32 = 3$ из 28 пар. Байес не отменяет счёт, а ставится поверх него, и ошибка в одном из трёх чисел ломает и знаменатель, и ответ.
Обоснование не сдаётся, принимается только число, поэтому задача берётся и так:
> import random > rng = random.Random(0) > u1 = ['W']*5 + ['B']*3 > hits = both = 0 > for _ in range(10**6): > t = rng.sample(u1, 2) > if rng.choice(['W']*2 + ['B']*6 + t) == 'W': > hits += 1 > both += (t == ['W', 'W']) > print(both / hits) # около 0.439 >
Миллион испытаний даёт три верных знака, четвёртый шумит: как ответ на экзамене это годится только при пустой строке, а как проверка формулы — полноценно.
Hypotheses. Let $H_2$ denote the event that two white balls were transferred, $H_1$ the event that one white and one black ball were transferred, and $H_0$ the event that two black balls were transferred. These cases are mutually exclusive and exhaustive.
Prior probabilities: count pairs in the first urn. There are $\binom{8}{2} = 28$ pairs in total:
$$\P(H_2) = \frac{\binom52}{28} = \frac{10}{28}, \qquad \P(H_1) = \frac{5 \cdot 3}{28} = \frac{15}{28}, \qquad \P(H_0) = \frac{\binom32}{28} = \frac{3}{28}$$Likelihoods. After the transfer, the second urn contains 10 balls. The number of white balls equals the 2 originally present plus the number transferred:
$$\P(W \mid H_2) = \frac{4}{10}, \qquad \P(W \mid H_1) = \frac{3}{10}, \qquad \P(W \mid H_0) = \frac{2}{10}$$Denominator: the law of total probability.
$$\P(W) = \frac{10}{28}\cdot\frac{4}{10} + \frac{15}{28}\cdot\frac{3}{10} + \frac{3}{28}\cdot\frac{2}{10} = \frac{40 + 45 + 6}{280} = \frac{91}{280} = \frac{13}{40} = 0.325$$Bayes' rule: reverse the conditioning.
$$\P(H_2 \mid W) = \frac{\P(W \mid H_2)\,\P(H_2)}{\P(W)} = \frac{40/280}{91/280} = \frac{40}{91} \approx 0.4396$$Before the final draw, the prior probability of “both transferred balls were white” was $\frac{10}{28} \approx 0.3571$. Drawing a white ball is evidence in favor of this hypothesis, so its posterior probability must increase rather than decrease: $0.4396 > 0.3571$ ✓. Also, $\P(W) = 0.325$ lies between the extreme likelihoods $0.2$ and $0.4$; otherwise, a factor has been lost somewhere.
The prior probabilities are pure combinatorics: $\binom52 = 10$, $5 \cdot 3 = 15$, and $\binom32 = 3$ out of 28 pairs. Bayes' rule does not replace counting; it is applied on top of it, and an error in any of these three numbers breaks both the denominator and the answer.
Only a number is submitted, not a justification, so the problem can also be approached as follows:
> import random > rng = random.Random(0) > u1 = ['W']*5 + ['B']*3 > hits = both = 0 > for _ in range(10**6): > t = rng.sample(u1, 2) > if rng.choice(['W']*2 + ['B']*6 + t) == 'W': > hits += 1 > both += (t == ['W', 'W']) > print(both / hits) # about 0.439 >
One million trials give three reliable decimal places, while the fourth fluctuates. This is suitable as an exam answer only if you have no analytical route, but it is fully adequate as a check of the formula.