Bayes theorem and conditional probability example.

519 views

Greetings to all.
I started an MSc that includes a course in statistics. Full disclosure: my bachelor’s had no courses of statics and it is in biology.

So, the professor was trying to explain the Bayes theorem and conditional probability through the following example.
“A friend of yours invites you over. He says he has 2 children. When you go over, a child opens the door for you and it is a boy. What is the probability that the other child is a boy as well.”

The math say the probability the other child is a boy is increased the moment we learn that one of the kids is a boy. Which i cannot wrap my head around, assuming that each birth is a separate event (the fact that a boy was born does not affect the result of the other birth), and the result of each birth can be a boy or a girl with 50/50 chance.
I get that “math says so” but… Could someone please explain? thank you

In: 77

24 Answers

Anonymous 0 Comments

Man I remember staying up until midnight trying to understand bayes rule and finish my probability hw. You have a lot of great discussion going already, so I’ll just say… the longer and harder you think about topics like these, the less they *seem* to make sense but the more you do actually understand them. Keep plugging away and don’t lose faith. You’ll get there.

Anonymous 0 Comments

Your professor is not applying the Bayes theorem correctly, and your gut feeling is right.

The Bayes theorem states that P(A|B) = P(B|A)*P(A)/P(B), where P(A) and P(B) are the probabilities of events A and B respectively and independently of each other without any other given conditions, P(A|B) is the probability of event A given that B is true, P(B|A) is the probability of event B given that A is true.

So let’s say that event A is both children being boys and event B is a boy opening the door. Then P(A) (the probability of both children being boys without any given condition) is 0.25, P(B) (the probability that a boy answers the door without any given condition) is 0.5, and P(B|A) (the probability that a boy answers the door given that both children are boys) is 1. Therefore P(A|B) – the probability of both children being boys given that a boy has opened the door – is equal to 1 * 0.25 / 0.5 = 0.5. This is the correct application of the Bayes theorem to the problem.

Edit: Also this is known as the Boy or Girl Paradox, and the answer to the problem really depends on the exact phrasing of how the information about the sex of at least one of the children is obtained: https://en.wikipedia.org/wiki/Boy_or_Girl_paradox

Anonymous 0 Comments

That example is wrong, and the probability is still 0.5.

A much better example of the Bayes theorem is false-positives and false-negatives.Suppose 0.0001% (one millionth) of the population have some disease X. You randomly decide to take a test for disease X.

Suppose the test that you take has a chance of 0.01% (one ten thousandths) of giving a false positive result, and the same probability of having a false negative result. You get your results, and they are positive. Which probability should you assign to having disease X?

Suppose event A is you having the disease, event B is you getting a positive result.

You need to find the probability P(A|B). You know that P(B|A) is 0.9999, and P(B|!A) is 0.0001.Then P(B) is P(B|A) * P(A) + P(B|!A) * P(!A) = 0.9999*0.000001 + 0.0001 * 0.999999= 0.0001009998 .Finally, P(A|B)= P(A) * P(B|A) / P(B) = 0.000001 * 0.9999 / 0.0001009998 = 0.00990002 .

So, your probability of having disease X is still only around 1/100 , despite testing positive with a pretty reliable test.

Anonymous 0 Comments

Your intuition is right and your professor is wrong. As are most of the people commenting here except /u/nmxt . They are making the same mistake.

Their logic goes : “well there are four *equally probable* initial possibilities. BB, BG, GB, and GG. And a boy answers the door, *eliminating* GG from the possibilities *and doing nothing else*. Therefore you’re left with BB, GB, and BG *of equal probability,* so therefore the other child has a 2/3 chance of being a girl.”

No. Wrong. Bullshit.

Your professor’s problem is the *bad assumption* that a boy answering the door *only alters the probability of the GG possibility*. In reality, it *also* alters the probability of the other 3 possibilities. Your professor is not applying the information gained from the sampling appropriately to all four houses.

Lets take our 3 remaining non-zero probable states, BB, BG, and GB. What is the probability of a boy answering the door at each of these houses? 100%, 50%, and 50%. (and 0% for the GG). If you go to one of these three houses and a boy answers, it is *twice* as likely that we are at a boy-only house than not. However, there are twice as many *kinds* of boy-girl houses. So in the end the odds of the other child being a girl is 0.25*0.5 + 0.25 * 0.5 vs 0.25 * 1. Which is just 0.25 vs 0.25, or 1:1, or 50%.

Let’s write this using Bayes’s law so you can show it to your professor:

>P(A given B) = P(B given A) * P(A) / P(B)

First off, is it correct to eliminate the GG house?

>P(GG|Boy) = P(Boy | GG) * P(GG) / P(Boy) = 0.0 x 0.25 / 0.5 = 0

Yes, the GG house is off the table.

But *we can’t stop there* What we want to know is the probability of *each* house we’re at GIVEN that a boy answered the door.

>P(BG|B) = ?, P(GB|B) = ?, P(BB|B) = ?

Starting with the boy-girl houses:

>P(BG|B) = P(B|BG) * P(BG)/P(B) = 0.5 x 0.25 / 0.5 = 0.25

Probability of the boy answering the door given a BG house, times the probability of a BG house, divided by the probability of a boy. That’s 50% times 25% divided by 50% = 25%. And the answer is identical for the GB house.

>P(BB | B) = P(B | BB) * P(BB) / P(B) = 1.0 x 0.25 / 0.5 = 0.5

Probability of the boy answering the door given a BB house, times the probability of a BB house, divided by the probability of a boy. That’s 100% times 25% divided by 50% = 50%.

So all together our four *weighted* possibilities are:

0.5 + 0.25 + 0.25 + 0.0 = 1.0

And of that 1.0, the chance of a BB house is 50%, and the aggregate chance for houses containing a girl are… 50%.

A boy answering the door has given you an altered probability of what type of house you may be at. But it has *not* altered the overall probability of the sex of the other child.

*Edit* – a key giveaway is that your professor’s scenario altered the probabilities from:
>0.25 + 0.25 + 0.25 + 0.25 -> 0.25 + 0.25 + 0.25 + 0.0

And then had to manually re-normalized by dividing by 0.75 to get
>0.33 + 0.33 + 0.33 + 0.0 = 1

Bayes’s theorem *handles* the re-normalization when correctly applied to all scenarios when given a new piece of information. That’s why I ended up with 0.5 + 0.25 + 0.25 + 0 = 1. If you are manually re-normalizing a sum of probabilities that *used* to add up to 1, then you’ve generally made a mistake and misapplied the theorum.

Anonymous 0 Comments

[deleted]

Anonymous 0 Comments

This really depends on how the questions is phrased precisely. But here is one way in which obtaining information changes the probability, or at least your belief in the evidence.

>A friend of yours invites you over. He says he has 2 children.

At this stage you are in one of four possible worlds: BB; BG; GB; GG

We will assume these have equal probability. So the probability of BB is 1/4.

>When you go over, a child opens the door for you and it is a boy. What is the probability that the other child is a boy as well.

We can now rule out the fourth world. We are either in BB; BG; or GB. We will also assume each child is equally likely to open the door. Therefore the probability of BB is 1/3.

It’s also worth pointing out that some interpretations of probability don’t allow claims about single events (e.g. [frequentist interpretation](https://en.wikipedia.org/wiki/Probability_interpretations)).

As an aside – are you saying your bachelor’s degree in biology had no statistics? How is that even possible?

Anonymous 0 Comments

The probability is 1/2 – can you tell us which math says it’s not 1/2?

Anonymous 0 Comments

Initially the odds that both kids are boys is 1 in 4. However if you know one of the kids is a boy then the odds the other kid is a boy is 1 in 2. The chance that both kids are boys goes up if we know that one of the kids is a boy.

It’s a poorly worded question for sure, but anyone saying the odds of both being boys only goes to 1 in 3 should read R2Dude2’s comment https://old.reddit.com/r/explainlikeimfive/comments/y8ucgq/eli5_bayes_theorem_and_conditional_probability/it2vxnx/ because you’re missing the probability that either kid answers the door. Not only does seeing a boy mean it’s not the girl girl scenario, but it’s also not the boy-girl scenarios where a girl answers the door which halves the boy girl scenarios as well.

Edit to clarify:
Of 4 houses 1 house has 2 boys (BB), 2 have 1 boy 1 girl (BG), and 1 has 2 girls (GG). The kid who answers the door is random (50-50). Since a boy answers the door you have to eliminate the GG house AND one of the BG houses where the girl answered the door (50-50), leaving 1 BG house (where the boy answers the door) and 1 BB house.

Anonymous 0 Comments

The example you give is difficult to understand because the language makes it ambiguous what is being asked.

Imagine two classrooms, A and B. Both have men and women attending class. Let’s say that there’s the same number of people in both classes, so if you picked as student at random there’s an equal chance that they came from room A or B (P(A) = P(B) = ½).

The classes differ in the fraction of the class that are women. Let’s says class A is ⅔ female, or in other words the probability that a person is female given that they are in class A (P(F|A)) is ⅔. In class B, women make up ½ the class, or the probability of a person being female given that they are from class B (P(F|B)) is ½.

If we know these facts, can we answer the question: if I selected a random student from the two classes, what’s the probability that they are from class A if the selected student were female (P(A|F)).

Bayes’ Rule tells us

P(A|F) = P(F|A) x P(A) / [P(F|A) x P(A) + P(F|B) x P(B)]

since we said that there’s the same number of students in each room, the P(A) and P(B) terms cancel out:

P(A|F) = P(F|A) / [P(F|A) + P(F|B)] = ⅔ / [⅔ + ½] = 4/7

… a bit more than half. Fair enough, there’s more women in room A than room B, right? Intuitively, you’ve you got two possibilities: the woman is from class A or class B, and we know there’s more women in A than in B.

As a matter of fact, if we multiplied the fraction of class that’s female by the size of the class, we get the number of women. Let’s just say the size of each class is 12 students: ⅔ of a class of 12 is 8. ½ of a class of 12 is 6. There are 14 women out of 24 students.

So, let’s use the actual count of students rather than the probabilities: P(F|A) -> 8 women, P(F|B) -> 6 women

P(A|F) = 8 / [8+6] = 8/14 … The chance that a woman is from class A is 8/14 because there are 8 women in class A out of a total of 14 across all the classes.

The reason for the P(A) and P(B) in Bayes’ formula is to weight the probabilities in case class A and class B are different sizes. It can also be extended to more class rooms by adding (P(F|…) x P(…)) in the denominator.

The probability of something, given a certain condition, is equal to the frequency of the condition divided by the sum of all the possibilities.

Anonymous 0 Comments

All of this discussion ignores the real answer, which is that the probability that the second child in this specific family is a boy is either exactly zero or exactly one because the child already exists and the outcome has been realized.

We really should have different words for aleatory and epistemic probability.