Conditional Probability & Bayes' Theorem

by Matt Enlow

Probability problems are notorious for yielding surprising and counterintuitive results. One famous example -- or pair of examples -- is the following:

1. A couple has two children and the older child is a boy. If the probabilities of having a boy or a girl are both 50%50\%, what is the probability that the couple has two boys?

We already know that the older child is a boy. The probability of two boys is equivalent to the probability that the younger child is a boy, which is 50%50\%.

2. A couple has two children, one of which is a boy. If the probabilities of having a boy or a girl are both 50%50\%, what is the probability that the couple has two boys?

At first glance, this appears to be asking the same question. We might reason as follows: “We know that one is a boy, so the only question is whether the other one is a boy, and the chances of that being the case are 50%50\%. So again, the answer is 50%50\%.”

This makes perfect sense. It also happens to be incorrect.

There are several approaches we could take to straighten out this logical tangle, as well as many other tangles that arise in probability. One common tool is known as Bayes’ Theorem. Before we state the theorem, we will discuss conditional probability.

When calculating probabilities of certain events, we often obtain new information that may cause our calculations to change. For example, if I draw a single card from a standard 5252-card deck and ask the probability that my card is a Heart, you would quickly say 1352=14\frac{13}{52}=\frac{1}{4}, as there are 1313 Hearts in the deck. However, if I then peek at the card and tell you that it is red, then we will have narrowed the possibilities for my card to 2626 possible cards, and the probability that my card is a Heart is now 1326=12\frac{13}{26}= \frac{1}{2}.

Let’s define the events EE and FF as “the card is a Heart”and “the card is red,” respectively. Our inital value of 14\frac{1}{4} is the probability that my card is a Heart before we have any other information about it. This is called the prior probability of event EE, and is denoted P(E)P(E). Once we take into account the knowledge that the card is red, we calculate that the posterior probability of the card being a Heart is 12\frac{1}{2}. This probability is denoted P(EF)P(E \mid F), and read “the probability of EE given FF.”

What about the values of P(F)P(F) and P(FE)P(F \mid E)? It’s clear that P(F)P(F), the prior probability that the card is red, is 2652=12\frac{26}{52}=\frac{1}{2}. To think about the posterior probability P(FE)P(F \mid E), we must ask, “What is the probability that the card is red, if we assume that it’s a Heart?” Phrased that way, the probability is clearly 100%100\%, or 11. Sometimes conditional probabilities are not this easy to calculate. For a given pair of events AA and BB, it is often the case that the value of one of P(AB)P(A \mid B) or P(BA)P(B \mid A) is much easier to calculate than the other. This is where Bayes’ Theorem comes to the rescue, by giving a relationship between these two conditional probabilities. There are several formulations of Bayes’ Theorem; we first state one of the simpler formulations.

Bayes’ Theorem

For any two events AA and BB,

P(AB)=P(A)P(BA)P(B).P(A \mid B) = \frac{P(A)P(B \mid A)}{P(B)}.

The proof of Bayes' Theorem follows from the fact that both P(B)P(AB)P(B) P(A \mid B) and P(A)P(BA)P(A) P(B \mid A) are equivalent to P(AB)P(A \cap B), the probability of both events occurring.

Example

Suppose you are given two coins. The first coin is fair and the second coin comes up Heads 75%75\% of the time. (You can’t tell from appearances which one is which.) You choose one of the coins and flip it three times, yielding Heads, Heads, and Tails (HHTHHT). Which coin is more likely to be the unfair one?

We want to find the probability that the coin we flipped is unfair, given that we flipped it three times and got HHTHHT. So let’s define event AA as “the coin we flipped is unfair,” and event BB as “the outcome of 3 flips was HHTHHT.” We want to find P(AB)P(A \mid B). To use Bayes’ Theorem, we must first determine P(A)P(A), P(BA)P(B \mid A), and P(B)P(B).

P(A)P(A) is the probability that the coin we flipped is unfair, without taking into account any flipping that took place. We can assume that we were just as likely to select the fair coin as we were to select the unfair one, so P(A)=12P(A)= \frac{1}{2}. P(BA)P(B \mid A) is the probability that the outcome is HHTHHT if the coin we flip is the unfair one. Since the unfair coin comes up Heads 75%75\% of the time, P(BA)=343414=964.P(B \mid A) = \frac{3}{4} \cdot \frac{3}{4} \cdot \frac{1}{4}= \frac{9}{64}. That leaves P(B)P(B), the probability that the outcome is HHTHHT if we pick either coin and flip it three times. Here, we come across a little bump in the road. “Well, that depends,” we say. “If it’s the fair coin, the probability is (12)3=18\left( \frac{1}{2} \right)^3 = \frac{1}{8}.

But if it’s the unfair coin, we just calculated that the probability is 964\frac{9}{64}. How can we calculate the probability if we don’t know whether or not the coin is fair?” We will use the fact that for any two sets AA and BB, the sets ABA \cap B and AB\overline{A} \cap B partition BB. This implies

P(B)=P(AB)+P(AB)=P(A)P(BA)+P(A)P(BA), P(B) = P(A \cap B) + P(\overline{A}\cap B) = P(A)P(B \mid A) + P(\overline{A})P(B \mid \overline{A}),

which gives us another formulation of Bayes’ Theorem:

P(AB)=P(A)P(BA)P(A)P(BA)+P(A)P(BA).P(A \mid B) = \frac{P(A)P(B \mid A)}{P(A)P(B \mid A) + P(\overline{A})P(B \mid \overline{A})}.

We can now plug everything in:

P(AB)=1296412964+1218=91752.94%.P(A \mid B) = \frac{ \frac{1}{2}\cdot \frac{9}{64} }{ \frac{1}{2}\cdot\frac{9}{64} + \frac{1}{2}\cdot \frac{1}{8} }=\frac{9}{17} \approx 52.94 \%.

Therefore, given the evidence of the flips, the coin we’ve been flipping is slightly more likely to be the unfair one. _\square

Diagnosing Disease

 One common application of Bayes’Theorem is in analyzing the quality of diagnostic tests. Consider the following.

The reliability of a particular skin test for tuberculosis (TB) is as follows: If the subject has TB, the test comes back positive 98%98\% of the time. If the subject does not have TB, the test comes back negative 99%99\% of the time. (Another way to say this is that the sensitivity of the test is 0.980.98, and the specificity of the test is 0.990.99.)

From a large population, in which 22 in every 10,00010,000 people have TB, a person is selected at random and given the test, which comes back positive. What is the probability that the person actually has TB?

Before we implement Bayes’Theorem, take a guess as to what the answer might be. (You might require some convincing that the answer is not simply 98%98\%!)

Let’s define event AA as “the person has TB” and event BB as “the person tests positive for TB”. It is clear that the prior probability P(A)P(A) is equal to 0.00020.0002 and P(A)=1P(A)=0.9998P(\overline{A})= 1 - P(A)=0.9998.

What about P(BA)P(B \mid A), the probability that the person will test positive for TB given that the person has TB? This was given to us as 0.980.98. The other value we need is P(BA)P(B \mid \overline{A}), the probability that the person will test positive for TB given that the person does not have TB. Since a person who does not have TB will test negative 99%99\% of the time, he or she will test positive 1%1\% of the time, and therefore P(BA)=0.01P(B \mid \overline{A})=0.01.  This implies

P(AB)=P(A)P(BA)P(A)P(BA)+P(A)P(BA)=0.0002×0.980,00020.98+0.99980.01=9850971.92%.\begin{aligned} P(A \mid B) &= \frac{ P(A) P(B \mid A)}{P(A)P(B\mid A) + P(\overline{A})P(B\mid \overline{A})} \\ & = \frac{0.0002 \times 0.98}{0,0002\cdot 0.98 + 0.9998 \cdot 0.01} \\ &= \frac{98}{5097} \\ & \approx 1.92 \%. \end{aligned}

You might find this hard to believe— that fewer than 2%2\% of people who test positive for TB using this test actually have the disease. Even though the sensitivity and specificity of this test are both high, the extremely low incidence of TB in the population has a tremendous effect on the test’s positive predictive value— the proportion of people who test positive that actually have the disease. To see this for yourself, you might try answering the same question assuming that the incidence of TB in the population is 22 in 100100 instead of 22 in 10,00010,000. _\square

Let’s see how to use Bayes’ Theorem to solve the two problems at the beginning of this post:

1. A couple has two children, the older of which is a boy. What is the probability that they have two boys?

2. A couple has two children, one of which is a boy. What is the probability that they have two boys?

Let’s define three events, AA, BB, and CC, as follows:

A= both children are boysB= the older child is a boyC= one of their children is a boy \begin{aligned} A & = \mbox{ both children are boys}\\ B & = \mbox{ the older child is a boy}\\ C & = \mbox{ one of their children is a boy} \end{aligned}

Question 1 is asking for P(AB)P(A \mid B), and Question 2 is asking for P(AC)P(A \mid C). The first is computed using the simpler version of Bayes’ Theorem:

P(AB)=P(A)P(BA)P(B)=14112=12.P(A \mid B) = \frac{P(A)P(B \mid A)}{P(B)} = \frac{ \frac{1}{4}\cdot 1 }{\frac{1}{2}} = \frac{1}{2}.

To find P(AC)P(A \mid C), we must determine P(C)P(C), the prior probability that the couple has at least one boy. This is equal to 1P(both children are girls)=114=341 - P(\mbox{both children are girls}) = 1 - \frac{1}{4}=\frac{3}{4}. Therefore the desired probability is

P(AC)=P(A)P(CA)P(C)=14134=13.    P(A \mid C) = \frac{P(A)P(C \mid A)}{P(C)} = \frac{\frac{1}{4}\cdot 1}{\frac{3}{4}} = \frac{1}{3}. \;\; _\square

There are probably simpler ways to come to an understanding of how these two questions are different. But Bayes’ Theorem is always an option, and an important tool to keep in our toolbox!

Practice Problems

The Paradox of the Second Ace

The following pair of problems come from Greg Ross’ wonderful blog, Futility Closet.

(1) You are watching four people play bridge, where a hand begins by dealing each player 13 cards.

a. After a hand is dealt, you ask a player, “Do you have at least one Ace?” She says, “Yes.” What is the probability that she’s holding more than one Ace?

b. On a later hand, you ask another player, “Do you have the Ace of Spades?” She says, “Yes.” What is the probability that she’s holding more than one Ace?

Taxi Hit-And-Run

The following problem is a favorite of Stanford professor and author Keith Devlin.

(2) A certain town has two taxi companies: Blue Birds, whose cabs are blue, and Night Owls, whose cabs are black. Blue Birds has 1515 taxis in its fleet, and Night Owls has 7575. Late one night, there is a hit-and-run accident involving a taxi. The town's 9090 taxis were all on the streets at the time of the accident. A witness saw the accident and claims that a blue taxi was involved.  At the request of the police, the witness undergoes a vision test under conditions similar to those on the night in question. Presented repeatedly with a blue taxi and a black taxi, in random order, he shows he can successfully identify the color of the taxi 44 times out of 55. Which company is more likely to have been involved in the accident?

Coin Tossing

(3) In front of you are two identical-looking coins. One is fair, and the other comes up Heads 90%90\% of the time. You choose one of the coins, and flip it ten times, yielding HTHHTHHHHTHTHHTHHHHT. What is the probability that the coin you’ve been flipping is the unfair one?

(4) In front of you are two identical-looking coins. One is fair, and the other comes up Heads 60%60\% of the time. You flip one of the coins five times, yielding HHTTHHHTTH. You flip the other coin three times, yielding THHTHH. Which one is more likely to be the unfair coin?

(5) In front of you are three identical-looking coins. Two are fair, and the third comes up Heads 80%80\% of the time. You flip one of the coins three times, yielding HTHHTH. You flip a second coin once, yielding H. Which coin is most likely to be the unfair one?

(6) You have three identical-looking coins in front of you. Two of them are fair, and the third comes up Heads 80%80\% of the time. You flip one of the coins twice, yielding THTH. You flip a second coin once, yielding HH. You are permitted to perform one more flip, with any coin you choose, after which you will be asked to identify which coin you believe to be the unfair one. Which coin should you flip in order to maximize the likelihood of your guessing correctly?

#Combinatorics #ConditionalProbability #Bayes'Theorem #Olympiad

Note by Calvin Lin
7 years, 2 months ago

No vote yet
1 vote

  Easy Math Editor

This discussion board is a place to discuss our Daily Challenges and the math and science related to those challenges. Explanations are more than just a solution — they should explain the steps and thinking strategies that you used to obtain the solution. Comments should further the discussion of math and science.

When posting on Brilliant:

  • Use the emojis to react to an explanation, whether you're congratulating a job well done , or just really confused .
  • Ask specific questions about the challenge or the steps in somebody's explanation. Well-posed questions can add a lot to the discussion, but posting "I don't understand!" doesn't help anyone.
  • Try to contribute something new to the discussion, whether it is an extension, generalization or other idea related to the challenge.
  • Stay on topic — we're all here to learn more about math and science, not to hear about your favorite get-rich-quick scheme or current world events.

MarkdownAppears as
*italics* or _italics_ italics
**bold** or __bold__ bold

- bulleted
- list

  • bulleted
  • list

1. numbered
2. list

  1. numbered
  2. list
Note: you must add a full line of space before and after lists for them to show up correctly
paragraph 1

paragraph 2

paragraph 1

paragraph 2

[example link](https://brilliant.org)example link
> This is a quote
This is a quote
    # I indented these lines
    # 4 spaces, and now they show
    # up as a code block.

    print "hello world"
# I indented these lines
# 4 spaces, and now they show
# up as a code block.

print "hello world"
MathAppears as
Remember to wrap math in \( ... \) or \[ ... \] to ensure proper formatting.
2 \times 3 2×3 2 \times 3
2^{34} 234 2^{34}
a_{i-1} ai1 a_{i-1}
\frac{2}{3} 23 \frac{2}{3}
\sqrt{2} 2 \sqrt{2}
\sum_{i=1}^3 i=13 \sum_{i=1}^3
\sin \theta sinθ \sin \theta
\boxed{123} 123 \boxed{123}

Comments

Can you please supply the answers to those problems so that we check our solution?

Titas Dutta - 6 years, 10 months ago

Where are the answers

robert forte - 6 years, 9 months ago

Very nicely written sir!

Snehal Shekatkar - 6 years, 8 months ago

There are two bags A and B. A contains n white and 2 black balls and B contains 2 white and n black balls. One of the two bags is selected at random and two balls are drawn from it without replacement. If both the balls drawn are white and the probability that the bag A was used to draw the balls is 6/7, find the value of n

zishan Ahmad - 5 years, 9 months ago

A nice written theory. Thanks sir. It provided a good insight into Bayes theorum

Pranav Rao - 5 years, 6 months ago

Under Diagnosing Disease, when calculating the probability of people testing positive for TB having TB, shouldn't the numerator notation be 0.0002*0.98 (multiplication) rather than subtraction (0.0002 - 0.98) as it is now? This does not affect the answer arrived at.

Christopher Williams - 5 years, 5 months ago

Log in to reply

Yes it should be. I've edited the page. Thanks!

Calvin Lin Staff - 5 years, 5 months ago
×

Problem Loading...

Note Loading...

Set Loading...