Зміст курсу
Основи Теорії Ймовірностей
Основи Теорії Ймовірностей
Умовна Ймовірність
Умовна ймовірність — це ймовірність настання події за умови, що інша подія вже відбулася. Вона відображає оновлену ймовірність на основі знань або інформації про настання іншої події.
Умовна ймовірність події A за умови B визначається так:
Якщо події A і B незалежні, тоді
P(A intersection B) = P(A)*P(B)
,
і, відповідно, умовна ймовірність P(A|B)=P(A)
.
Примітка
Введення умовної ймовірності має сенс лише тоді, коли P(B) не дорівнює нулю.
Розглянемо приклад.
У сім’ї 5
дітей, і кожна дитина однаково ймовірно може бути хлопчиком або дівчинкою з ймовірністю 50%
.
Відомо, що принаймні одна з дітей — дівчинка. Обчисліть ймовірність того, що найстарша дитина — хлопчик.
Для розв’язання використовуйте умовну ймовірність, де:
Подія A — найстарша дитина є хлопчиком.
Подія B — серед 5 дітей є принаймні одна дівчинка.
import numpy as np # Firstly let's calculate the number of all possible outcomes # There are 5 children, each child can be a boy or a girl. num_combinations = 2**5 # Let's consider event B # There is only one possible variant when there are no girls in the family num_B = num_combinations - 1 p_B = num_B / num_combinations # Now let's consider event A intersection event B # We fix the fact that the eldest child is a boy, in this case there are four children num_comb_4_children = 2**4 # Now we can calculate number of combinations when the eldest child is a boy # and there is at least one girl # There is only one combination when the eldest child is a boy and there are no girls num_A_and_B = num_comb_4_children - 1 p_A_and_B = num_A_and_B / num_combinations # At least we can calculate conditional probability cond_prob = p_A_and_B / p_B # Print the results print(f'Probability that the eldest is a boy and there is at least one girl is {cond_prob:.4f}')
Дякуємо за ваш відгук!