We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Day 3: Conditional Probability
Day 3: Conditional Probability
Sort by
recency
|
181 Discussions
|
Please Login in order to post a comment
I was so confused that I was calculating the probability that the gender of the second child is "male", instead of calculating the probability that both children are boys... 1/3
Bayes' theorem is a powerful tool for problems like this. Let's use it to solve the problem.
Let ( B_1 ) be the event that the first child is a boy and ( B_2 ) be the event that the second child is a boy.
We want to find the probability that both children are boys given that at least one of them is a boy. In terms of events, we want to find:
[ P(B_1 \cap B_2 | B_1 \cup B_2) ]
Using Bayes' theorem:
[ P(B_1 \cap B_2 | B_1 \cup B_2) = \frac{P(B_1 \cup B_2 | B_1 \cap B_2) \times P(B_1 \cap B_2)}{P(B_1 \cup B_2)} ]
Now, let's break down each of these probabilities:
( P(B_1 \cup B_2 | B_1 \cap B_2) ): If both children are boys, then the probability that at least one of them is a boy is 1. So, ( P(B_1 \cup B_2 | B_1 \cap B_2) = 1 ).
( P(B_1 \cap B_2) ): This is the probability that both children are boys. Since the children's genders are independent and each has a ( \frac{1}{2} ) chance of being a boy, ( P(B_1 \cap B_2) = \frac{1}{2} \times \frac{1}{2} = \frac{1}{4} ).
( P(B_1 \cup B_2) ): This is the probability that at least one child is a boy. From our initial list of combinations (BB, BG, GB, GG), three of them have at least one boy. So, ( P(B_1 \cup B_2) = \frac{3}{4} ).
Plugging these values into Bayes' theorem:
[ P(B_1 \cap B_2 | B_1 \cup B_2) = \frac{1 \times \frac{1}{4}}{\frac{3}{4}} = \frac{1}{3} ]
So, using Bayes' theorem, we again find that the probability that both children are boys, given that at least one of them is a boy, is ( \frac{1}{3} ).
Simply put, when you have a previous condition you end up altering the samples.
At first, if a couple has 2 children, you samples are (B,G)(B,B)(G,B)(G,G). But now you know one of them is a boy, which changes your samples to (B,G)(B,B)(G,B). Thus the probability is now 1/3.
from itertools import product
from fractions import Fraction
since the family has 2 childrens and one of them is boy. however, they did not mentioned whether first born is a boy or second born is a boy. so the possibilities are:S1 = ['B','G'] # considering first children born is boy
S2 = ['G','B'] # considering first children born is girl
sample_space = [(s1,s2) for s1,s2 in product(S1,S2) if [s1,s2]!=['G','G']]
sample_length = len(sample_space)
filtered = [(s1,s2) for s1,s2 in product(S1,S2) if (s1==s2) and [s1,s2]!=['G','G']]
filtered_length = len(filtered)
print(filtered)
print(filtered_length)
print(sample_length)
print(Fraction(filtered_length, sample_length))
P(both boys | 1 boy) = P(1 boy | both boys) * P(both boys) / P(1 boy)
P(1 boy | both boys) = 1 as %100 possibility P(both boys) = 1/2 * 1/2 as 0.5 probability for each child without prior information P(1 boy) = P(1 boy | both boys) * P(both boys) + P(1 boy | NOT[both boys]) * P(NOT[both boys]) = 1 * 1/4 + 2/3 * 3/4 = 3/4 Therefore, P(both boys | 1 boy) = (1 * 1/4) / 3/4 = 1/3
All possibilities: AP = [g,b; b,g; b,b; g,g];