Discrete MathematicsProbability, Conditioning and Expectation5 of 9
Probability, Conditioning and Expectation · 5

Bayes' Theorem

When we see a test result or a piece of evidence, we often need to work backward from that evidence to find the probability of the hidden cause that produced it.

1

Going Backward from Evidence to Cause

Given the evidence we observe, we want to find the probability of the underlying cause. From conditional probability, conditioning on an event B\evidence{B} means erasing everything outside B\evidence{B} and taking the ratio of the overlap to what is left, using the multiplication rule to find the overlap:

P(A∣B)=P(A and B)P(B),P(A and B)=P(A)⋅P(B∣A)\displaystyle \begin{aligned} P(\cause{A} \mid \evidence{B}) &= \frac{\piece{P(A \text{ and } B)}}{\evidence{P(B)}}, \\ \piece{P(A \text{ and } B)} &= P(\cause{A}) \cdot P(\evidence{B} \mid \cause{A}) \end{aligned}

Suppose 1%1\% of a population has a silent virus and 99%99\% are healthy. A lab test catches the virus 90%90\% of the time in sick people, but also gives a false alarm 10%10\% of the time in healthy people. If you test positive, what is the probability that you actually have the virus?

Going Backward from Evidence to Cause
Bag A\text{Bag A}
Bag B\htmlClass{lc-pink}{\text{Bag B}}
?\htmlClass{lc-pink}{?}
Text solution
Split 1,000 people by causeBefore anyone takes the test, divide a square of 1,0001{,}000 people into a sick column (1%1\%) and a healthy column (99%99\%).
Sick=1,000×0.01=10,Healthy=1,000×0.99=990\displaystyle \begin{aligned} \cause{\text{Sick}} &= 1{,}000 \times 0.01 = \cause{10}, \\ \text{Healthy} &= 1{,}000 \times 0.99 = 990 \end{aligned}
Shade the positive tests in each columnTake 90%90\% of the sick group for the true positives and 10%10\% of the healthy group for the false alarms.
Sick andPositive=10×0.90=9,Healthy and Positive=990×0.10=99\displaystyle \begin{aligned} \piece{\text{Sick and}} & \\[-2pt] \piece{\text{Positive}} &= \cause{10} \times 0.90 = \piece{9}, \\[8pt] \text{Healthy and } & \\[-2pt] \evidence{\text{Positive}} &= 990 \times 0.10 = 99 \end{aligned}
Divide true positives by all positivesThrow away everyone who tested negative, and find the fraction of the remaining positive results that came from the sick column.
P(Sick∣Positive)\displaystyle P(\cause{\text{Sick}} \mid \evidence{\text{Positive}}) =99+99\displaystyle = \frac{\piece{9}}{\piece{9} + 99} =9108\displaystyle = \frac{\piece{9}}{\evidence{108}} =112≈8.3%\displaystyle = \frac{1}{12} \approx 8.3\%

So a positive result only gives an 8.3%8.3\% chance of having the virus, because the massive healthy column produces eleven times as many positive tests as the tiny sick column.

When the sick column is very thin, the short, wide false-alarm strip in the healthy column has much more area than the tall, skinny true-positive strip; the true positives only overtake the false alarms once the sick column starts out wide enough.

Even with the same test, the chance that a person who tests positive is actually sick depends on how common the sickness is to begin with.
2

Bayes' Formula: Long and Short Forms

Instead of imagining 1,0001{,}000 people every time, we want to compute this backward probability directly from decimals, whether a problem gives us separate rates inside each group or the overall rate of the evidence across everyone.

Suppose 20%20\% of all emails in your inbox are spam, 15%15\% of spam emails contain the word "Winner", and 5%5\% of all emails overall contain the word "Winner". If a new email contains the word "Winner", what is the probability that it is spam?

Bayes' Formula: Long and Short Forms
Sick\htmlClass{lc-pink}{\text{Sick}}
Healthy\text{Healthy}
Positive\htmlClass{lc-blue}{\text{Positive}}
0.010.01
0.990.99
0.900.90
0.100.10
P(Sick∣Positive)= ?P(\htmlClass{lc-pink}{\text{Sick}} \mid \htmlClass{lc-blue}{\text{Positive}}) = \,?
P(H)P(\htmlClass{lc-pink}{H})
P(¬H)P(\neg H)
P(E∣H)P(\htmlClass{lc-blue}{E} \mid \htmlClass{lc-pink}{H})
P(E∣¬H)P(\htmlClass{lc-blue}{E} \mid \neg H)
E\htmlClass{lc-blue}{E}
P(H)P(\htmlClass{lc-pink}{H})
H\htmlClass{lc-pink}{H}
P(¬H)P(\neg H)
¬H\neg H
P(E∣H)P(\htmlClass{lc-blue}{E} \mid \htmlClass{lc-pink}{H})
E\htmlClass{lc-blue}{E}
P(E∣¬H)P(\htmlClass{lc-blue}{E} \mid \neg H)
E\htmlClass{lc-blue}{E}

Writing H\cause{H} for the hypothesis (the cause) and E\evidence{E} for the evidence gives both forms of Bayes' Theorem. The long form adds the shaded boxes from each column in the denominator, while the short form writes their sum as a single number P(E)\evidence{P(E)}:

P(H∣E)=P(H)⏞Prior (width)⋅P(E∣H)⏞Likelihood (height)P(H)⋅P(E∣H)⏟Left shaded box+P(¬H)⋅P(E∣¬H)⏟Right shaded box=P(H)⋅P(E∣H)P(E)⏟Total probability of E\displaystyle \begin{aligned} P(\cause{H} \mid \evidence{E}) &= \frac{\overbrace{P(\cause{H})}^{\text{Prior (width)}} \cdot \overbrace{P(\evidence{E} \mid \cause{H})}^{\text{Likelihood (height)}}}{\begin{aligned} &\underbrace{P(\cause{H}) \cdot P(\evidence{E} \mid \cause{H})}_{\text{Left shaded box}} \\ &+ \underbrace{P(\neg H) \cdot P(\evidence{E} \mid \neg H)}_{\text{Right shaded box}} \end{aligned}} \\ &= \frac{P(\cause{H}) \cdot P(\evidence{E} \mid \cause{H})}{\underbrace{\evidence{P(E)}}_{\text{Total probability of } E}} \end{aligned}
Text solution
Find the spam emails with "Winner"Multiply the starting share of spam (width) by the rate of "Winner" inside spam (height).
P(Spam and Winner)=P(Spam)⋅P(Winner∣Spam)=0.20×0.15=0.03\displaystyle \begin{aligned} &\piece{P(\text{Spam and Winner})} \\ &\quad = P(\cause{\text{Spam}}) \\ &\qquad \cdot P(\evidence{\text{Winner}} \mid \cause{\text{Spam}}) \\ &\quad = 0.20 \times 0.15 = \piece{0.03} \end{aligned}
Divide by all emails with "Winner"Because the problem already gives the total shaded area P(Winner)=0.05\evidence{P(\text{Winner})} = \evidence{0.05} across the whole inbox, divide by it directly with the short form.
P(Spam∣Winner)\displaystyle P(\cause{\text{Spam}} \mid \evidence{\text{Winner}}) =0.030.05\displaystyle = \frac{\piece{0.03}}{\evidence{0.05}} =0.60\displaystyle = 0.60 =60%\displaystyle = 60\%

So 60%60\% of the emails containing the word "Winner" are spam.

3

Three or More Causes

Now suppose the evidence can come from three or more mutually exclusive causes that partition the sample space, and we want the probability that one specific cause produced it.

A company makes microchips at three factories: Factory A makes 50%50\% of the chips (with a 2%2\% defect rate), Factory B makes 30%30\% (with a 4%4\% defect rate), and Factory C makes 20%20\% (with a 5%5\% defect rate). If a randomly selected chip is defective, what is the probability that it came from Factory C?

Three or More Causes
defective\htmlClass{lc-blue}{\text{defective}}
Factory A\text{Factory A}
50%50\%
2%2\%
Factory B\text{Factory B}
30%30\%
4%4\%
Factory C\htmlClass{lc-pink}{\text{Factory C}}
20%20\%
5%5\%
A (0.50)\text{A}\ (0.50)
B (0.30)\text{B}\ (0.30)
C (0.20)\htmlClass{lc-pink}{\text{C}\ (0.20)}
P(C∣Defective)= ?P(\htmlClass{lc-pink}{\text{C}} \mid \htmlClass{lc-blue}{\text{Defective}}) = \,?
Text solution
Find the defective share from each factoryMultiply each factory's share of total production (width) by its defect rate (height).
P(A and Defective)=0.50×0.02=0.010P(B and Defective)=0.30×0.04=0.012P(C and Defective)=0.20×0.05=0.010\displaystyle \begin{aligned} &P(A \text{ and } \evidence{\text{Defective}}) \\ &\quad = 0.50 \times 0.02 = 0.010 \\[6pt] &P(B \text{ and } \evidence{\text{Defective}}) \\ &\quad = 0.30 \times 0.04 = 0.012 \\[6pt] &\piece{P(C \text{ and Defective})} \\ &\quad = 0.20 \times 0.05 = \piece{0.010} \end{aligned}
Divide Factory C's defective share by all defective chipsPut Piece C on top and the sum of all three defective pieces on the bottom.
P(C∣Defective)=0.0100.010+0.012+0.010=0.0100.032=1032=31.25%\displaystyle \begin{aligned} &P(\cause{C} \mid \evidence{\text{Defective}}) \\ &\quad = \frac{\piece{0.010}}{0.010 + 0.012 + \piece{0.010}} \\ &\quad = \frac{\piece{0.010}}{\evidence{0.032}} = \frac{\piece{10}}{\evidence{32}} = 31.25\% \end{aligned}

Even though Factory C has the highest defect rate, it only accounts for 31.25%31.25\% of all defective chips because it makes the smallest share of the company's chips. Multiplying the decimals by 1,0001{,}000 to think in whole chips (1010, 1212, and 10\piece{10}) is a great way to avoid decimal-place slips; just write the probability steps alongside it.

4

Repeated Evidence and Bayesian Updating

When a second or third piece of evidence comes in on the same case, we want to find the updated probability of the cause without starting over from scratch.

In our virus test from earlier (1%1\% of people are sick, 90%90\% true-positive rate, 10%10\% false-alarm rate), a single positive test left 9\piece{9} sick people and 9999 healthy people out of 1,0001{,}000, or an 8.3%8.3\% chance of being sick. If the same person takes the test a second time and tests positive again, with the two results independent within the sick group and within the healthy group, what is the probability that they are sick?

Repeated Evidence and Bayesian Updating
1%  ⟶  9108≈8.3%\htmlClass{lc-pink}{1\%} \;\longrightarrow\; \dfrac{\htmlClass{lc-green}{9}}{\htmlClass{lc-blue}{108}} \approx 8.3\%
Sick (10)\htmlClass{lc-pink}{\text{Sick}\ (10)}
Healthy (990)\text{Healthy}\ (990)
Positive\htmlClass{lc-blue}{\text{Positive}}
9\htmlClass{lc-green}{9}
9999
P(Sick∣2 Positives)= ?P(\htmlClass{lc-pink}{\text{Sick}} \mid \htmlClass{lc-blue}{\text{2 Positives}}) = \,?
Text solution
Use the people who tested positive the first time as the new priorStart with the 9\piece{9} sick and 9999 healthy people who tested positive the first time, since everyone who tested negative is already ruled out.
Shade the second positive test inside each groupBecause the tests are independent within each group, multiply the remaining sick group by 0.900.90 and the remaining healthy group by 0.100.10.
Sick with2 Positives=9×0.90=8.1,Healthy with 2 Positives=99×0.10=9.9\displaystyle \begin{aligned} \piece{\text{Sick with}} & \\[-2pt] \piece{\text{2 Positives}} &= \piece{9} \times 0.90 = \piece{8.1}, \\[8pt] \text{Healthy with } & \\[-2pt] \evidence{\text{2 Positives}} &= 99 \times 0.10 = 9.9 \end{aligned}
Divide the remaining sick group by everyone with two positivesTake the ratio of the twice-shaded pieces, which is the same as squaring each test rate from the original 1,0001{,}000 people.
P(Sick∣2 Positives)=8.18.1+9.9=10×0.90210×0.902+990×0.102=8.118=45%\displaystyle \begin{aligned} &P(\cause{\text{Sick}} \mid \evidence{\text{2 Positives}}) \\ &\quad = \frac{\piece{8.1}}{\piece{8.1} + 9.9} \\ &\quad = \frac{\cause{10} \times 0.90^2}{\cause{10} \times 0.90^2 + 990 \times 0.10^2} \\ &\quad = \frac{\piece{8.1}}{\evidence{18}} = 45\% \end{aligned}

So a second positive test raises the probability of having the virus from 8.3%8.3\% to 45%45\%, and a third positive test pushes it to 8.1×0.908.1×0.90+9.9×0.10≈88%\frac{\piece{8.1} \times 0.90}{\piece{8.1} \times 0.90 + 9.9 \times 0.10} \approx 88\%.

Across the three repeated tests below, the shaded pieces from each test expand to become the starting columns for the next test; when the false-alarm rate is small, each positive result cuts away most of the remaining healthy column so the sick column rapidly dominates.

Each positive test's shaded pieces become the next test's starting columns, so a low false-alarm rate quickly clears out the Healthy column across repeated tests.

Key concepts

Before reaching for Bayes' Theorem, check the direction of the question. If a problem gives you the cause and asks for the evidence, such as "if a person is sick, what is the chance they test positive?", that is a forward probability P(E∣H)=0.90P(\evidence{E} \mid \cause{H}) = 0.90 that you read directly from the problem. You only use Bayes' Theorem when the problem hands you the evidence E\evidence{E} and asks you to go backward to the cause H\cause{H}.

Once you know you are going backward, check how the denominator is given:

Overall rate of evidence P(E)\evidence{P(E)} given (Short form)

When the problem states the rate of the evidence across the entire population at once, divide the overlap by P(E)\evidence{P(E)} directly without building other columns:

P(H∣E)=P(H)⋅P(E∣H)P(E)(Spam given Winner: 0.20×0.150.05=60%)\displaystyle \begin{gathered} P(\cause{H} \mid \evidence{E}) = \frac{P(\cause{H}) \cdot P(\evidence{E} \mid \cause{H})}{\evidence{P(E)}} \\ \Big(\cause{\text{Spam}}\text{ given }\evidence{\text{Winner}}\text{: } \\ \frac{\piece{0.20 \times 0.15}}{\evidence{0.05}} = 60\%\Big) \end{gathered}

Separate rates given for each group (Long form)

When the problem splits the sample space into mutually exclusive causes (H1,H2,…\cause{H_1}, H_2, \dots) and gives a separate rate inside each one, multiply Width×Height\text{Width} \times \text{Height} in every column and divide the piece you want by the sum of all shaded pieces:

P(H1∣E)=P(H1)⋅P(E∣H1)P(H1)⋅P(E∣H1)+P(H2)⋅P(E∣H2)+⋯(Sick given Positive: 0.01×0.900.01×0.90+0.99×0.10=112)\displaystyle \begin{gathered} \begin{aligned} &P(\cause{H_1} \mid \evidence{E}) \\ &\quad = \frac{P(\cause{H_1}) \cdot P(\evidence{E} \mid \cause{H_1})}{\begin{aligned} &P(\cause{H_1}) \cdot P(\evidence{E} \mid \cause{H_1}) \\ &+ P(H_2) \cdot P(\evidence{E} \mid H_2) + \cdots \end{aligned}} \end{aligned} \\ \Big(\cause{\text{Sick}}\text{ given }\evidence{\text{Positive}}\text{: } \\ \frac{\piece{0.01 \times 0.90}}{\piece{0.01 \times 0.90} + 0.99 \times 0.10} = \frac{1}{12}\Big) \end{gathered}

Repeated evidence (Bayesian updating)

When multiple trials or tests happen in a row, the updated probability from the first test becomes the starting prior for the next test. Multiply the new likelihood inside each group rather than multiplying overall probabilities outside the columns:

Two positive tests: 9×0.909×0.90+99×0.10=10×0.90210×0.902+990×0.102=45%\displaystyle \begin{aligned} &\text{Two positive tests: } \\ &\quad \frac{\piece{9} \times 0.90}{\piece{9} \times 0.90 + 99 \times 0.10} \\ &\quad = \frac{\cause{10} \times 0.90^2}{\cause{10} \times 0.90^2 + 990 \times 0.10^2} \\ &\quad = 45\% \end{aligned}

5

Practice

1

At an airport, 15%15\% of all flights are delayed, 4%4\% of all flights are international, and 30%30\% of international flights are delayed. If a randomly chosen flight is delayed, what is the probability that it is an international flight?

Look at the 15%15\% delay rate: is that for one group of flights, or across the entire airport?

Find the share of flights that are both international and delayed:
P(International and Delayed)=P(International)⋅P(Delayed∣International)=0.04×0.30=0.012\displaystyle \begin{aligned} &\piece{P(\text{International and Delayed})} \\ &\quad = P(\cause{\text{International}}) \\ &\qquad \cdot P(\evidence{\text{Delayed}} \mid \cause{\text{International}}) \\ &\quad = 0.04 \times 0.30 = \piece{0.012} \end{aligned}
Because 15%\evidence{15\%} is already the overall delay rate P(Delayed)=0.15\evidence{P(\text{Delayed})} = \evidence{0.15} across all flights, divide by 0.15\evidence{0.15} directly using the short form. (Watch out: don't treat 0.150.15 as the delay rate for domestic flights and build a second column 0.012+0.96×0.15=0.1560.012 + 0.96 \times 0.15 = 0.156, which gives the wrong answer 113≈7.7%\wrong{\frac{1}{13} \approx 7.7\%}.)
P(International∣Delayed)\displaystyle P(\cause{\text{International}} \mid \evidence{\text{Delayed}}) =0.0120.15\displaystyle = \frac{\piece{0.012}}{\evidence{0.15}} =12150\displaystyle = \frac{\piece{12}}{\evidence{150}} =225\displaystyle = \frac{2}{25} =8%\displaystyle = 8\%
2

A company gives a lie detector test to job applicants, 5%5\% of whom are lying about their background. If an applicant is lying, the test flags them 80%80\% of the time. If an applicant is telling the truth, the test gives a false alarm 10%10\% of the time. If an applicant is flagged by the test, what is the probability that they are actually lying?

Split the applicants into two columns, Lying (5%5\%) and Truthful (95%95\%), and find the flagged share inside each column.

Multiply width times height in each column to find the true positives and the false alarms:
P(Lying and Flagged)=0.05×0.80=0.040,P(Truthful and Flagged)=0.95×0.10=0.095\displaystyle \begin{aligned} &\piece{P(\text{Lying and Flagged})} \\ &\quad = 0.05 \times 0.80 = \piece{0.040}, \\[6pt] &P(\text{Truthful and } \evidence{\text{Flagged}}) \\ &\quad = 0.95 \times 0.10 = 0.095 \end{aligned}
Divide the lying-and-flagged piece by the sum of both flagged pieces. (Watch out: ignoring the 5%5\% and 95%95\% base-rate widths and just dividing the test heights 0.800.80+0.10\frac{0.80}{0.80 + 0.10} gives the wrong answer 89≈88.9%\wrong{\frac{8}{9} \approx 88.9\%}.)
P(Lying∣Flagged)=0.0400.040+0.095=0.0400.135=827≈29.6%\displaystyle \begin{aligned} &P(\cause{\text{Lying}} \mid \evidence{\text{Flagged}}) \\ &\quad = \frac{\piece{0.040}}{\piece{0.040} + 0.095} = \frac{\piece{0.040}}{\evidence{0.135}} \\ &\quad = \frac{8}{27} \approx 29.6\% \end{aligned}
3

In a storage bin, 10%10\% of the batteries are weak and 90%90\% are good. A voltage tester catches and rejects a weak battery 95%95\% of the time, but also falsely rejects 5%5\% of good batteries. If a battery passes the test, what is the probability that it is actually weak?

Look carefully at the evidence we saw: the battery passed the test, so what height should you shade in each column instead of the rejection rates?

Subtract each rejection rate from 11 to get the pass rate inside each group: P(Pass∣Weak)=1−0.95=0.05P(\evidence{\text{Pass}} \mid \cause{\text{Weak}}) = 1 - 0.95 = 0.05 and P(Pass∣Good)=1−0.05=0.95P(\evidence{\text{Pass}} \mid \text{Good}) = 1 - 0.05 = 0.95. (Watch out: plugging the rejection rates 0.950.95 and 0.050.05 straight in finds P(Weak∣Rejected)P(\cause{\text{Weak}} \mid \wrong{\text{Rejected}}) instead of P(Weak∣Pass)P(\cause{\text{Weak}} \mid \evidence{\text{Pass}}), giving the wrong answer 1928≈67.9%\wrong{\frac{19}{28} \approx 67.9\%}.)
P(Weak and Pass)=0.10×0.05=0.005,P(Good and Pass)=0.90×0.95=0.855\displaystyle \begin{aligned} &\piece{P(\text{Weak and Pass})} \\ &\quad = 0.10 \times 0.05 = \piece{0.005}, \\[6pt] &P(\text{Good and } \evidence{\text{Pass}}) \\ &\quad = 0.90 \times 0.95 = 0.855 \end{aligned}
Divide the weak batteries that pass by all batteries that pass:
P(Weak∣Pass)=0.0050.005+0.855=0.0050.860=1172≈0.58%\displaystyle \begin{aligned} &P(\cause{\text{Weak}} \mid \evidence{\text{Pass}}) \\ &\quad = \frac{\piece{0.005}}{\piece{0.005} + 0.855} = \frac{\piece{0.005}}{\evidence{0.860}} \\ &\quad = \frac{1}{172} \approx 0.58\% \end{aligned}
4

An online store ships orders using three couriers: FastShip handles 50%50\% of orders, QuickPost handles 30%30\%, and ValueMail handles 20%20\%. Packages arrive late 2%2\% of the time with FastShip, 5%5\% of the time with QuickPost, and 10%10\% of the time with ValueMail. If an order arrives late, what is the probability it was shipped via ValueMail?

Set up three columns for the three couriers and find the share of late orders coming from each one.

Multiply each courier's share of orders by its late rate:
P(FastShip and Late)=0.50×0.02=0.010P(QuickPost and Late)=0.30×0.05=0.015P(ValueMail and Late)=0.20×0.10=0.020\displaystyle \begin{aligned} &P(\text{FastShip and } \evidence{\text{Late}}) \\ &\quad = 0.50 \times 0.02 = 0.010 \\[6pt] &P(\text{QuickPost and } \evidence{\text{Late}}) \\ &\quad = 0.30 \times 0.05 = 0.015 \\[6pt] &\piece{P(\text{ValueMail and Late})} \\ &\quad = 0.20 \times 0.10 = \piece{0.020} \end{aligned}
Put ValueMail's piece on top and the sum of all three pieces on the bottom. (Watch out: make sure ValueMail's 0.020\piece{0.020} is on top rather than the first courier listed, and include all three couriers in the denominator. Dividing by only the other two couriers 0.010+0.015=0.0250.010 + 0.015 = 0.025 gives the wrong answer 45=80%\wrong{\frac{4}{5} = 80\%}.)
P(ValueMail∣Late)=0.0200.010+0.015+0.020=0.0200.045=49≈44.4%\displaystyle \begin{aligned} &P(\cause{\text{ValueMail}} \mid \evidence{\text{Late}}) \\ &\quad = \frac{\piece{0.020}}{0.010 + 0.015 + \piece{0.020}} \\ &\quad = \frac{\piece{0.020}}{\evidence{0.045}} = \frac{4}{9} \approx 44.4\% \end{aligned}
5

A bag contains 99 fair coins and 11 double-headed coin (which lands on Heads every time). You reach in, pull out one coin at random, and flip it 44 times, getting Heads all 44 times. What is the probability that you pulled out the double-headed coin?

Once you pick a coin, the 44 flips are independent. What is the probability of getting 44 Heads in a row inside the double-headed column versus inside the fair-coin column?

The prior widths are P(Double-headed)=110P(\cause{\text{Double-headed}}) = \frac{1}{10} and P(Fair)=910P(\text{Fair}) = \frac{9}{10}. Inside each column, raise the single-flip Heads probability to the 44th power: 14=11^4 = 1 for the double-headed coin and (12)4=116\left(\frac{1}{2}\right)^4 = \frac{1}{16} for a fair coin. (Watch out: forgetting to raise 12\frac{1}{2} to the 44th power treats the evidence as a single flip and gives the wrong answer 211≈18.2%\wrong{\frac{2}{11} \approx 18.2\%}, while raising the entire product (910×12)4\left(\frac{9}{10} \times \frac{1}{2}\right)^4 to the 44th power acts as if you drew a new coin on every flip.)
P(Double-headed and 4 Heads)=110×14=110,P(Fair and 4 Heads)=910×(12)4=9160\displaystyle \begin{aligned} &\piece{P(\text{Double-headed and 4 Heads})} \\ &\quad = \frac{1}{10} \times 1^4 = \piece{\frac{1}{10}}, \\[6pt] &P(\text{Fair and } \evidence{\text{4 Heads}}) \\ &\quad = \frac{9}{10} \times \left(\frac{1}{2}\right)^4 = \frac{9}{160} \end{aligned}
Divide the double-headed piece by the total probability of getting 44 Heads:
P(Double-headed∣4 Heads)=110110+9160=1616025160=1625=64%\displaystyle \begin{aligned} &P(\cause{\text{Double-headed}} \mid \evidence{\text{4 Heads}}) \\ &\quad = \frac{\piece{\frac{1}{10}}}{\piece{\frac{1}{10}} + \frac{9}{160}} = \frac{\piece{\frac{16}{160}}}{\evidence{\frac{25}{160}}} \\ &\quad = \frac{16}{25} = 64\% \end{aligned}
6

A rare condition affects 1%1\% of a population. An initial screening test catches the condition 90%90\% of the time and has a 10%10\% false-alarm rate. Anyone who tests positive on the screening test takes an independent follow-up test that catches the condition 80%80\% of the time and has a 4%4\% false-alarm rate. If a person tests positive on both tests, what is the probability that they actually have the condition?

Start from the 99 sick and 9999 healthy people out of 1,0001{,}000 who test positive on the first screening test, and apply the follow-up test's rates to those two groups.

Out of 1,0001{,}000 people, the first screening test leaves 10×0.90=9\cause{10} \times 0.90 = \piece{9} people with the condition and 990×0.10=99990 \times 0.10 = 99 healthy people. Use these two groups as the prior for the follow-up test, multiplying by 0.800.80 and 0.040.04. (Watch out: don't go back to the original 10\cause{10} and 990990 people for the second test without keeping the first test's rates, which ignores the screening test and gives the wrong answer 20119≈16.8%\wrong{\frac{20}{119} \approx 16.8\%}.)
Condition andBoth Positive=9×0.80=7.2,Healthy and Both Positive=99×0.04=3.96\displaystyle \begin{aligned} \piece{\text{Condition and}} & \\[-2pt] \piece{\text{Both Positive}} &= \piece{9} \times 0.80 = \piece{7.2}, \\[8pt] \text{Healthy and } & \\[-2pt] \evidence{\text{Both Positive}} &= 99 \times 0.04 = 3.96 \end{aligned}
Divide the remaining people with the condition by everyone who tested positive on both tests:
P(Condition∣Both Positive)=7.27.2+3.96=7.2011.16=2031≈64.5%\displaystyle \begin{aligned} &P(\cause{\text{Condition}} \mid \evidence{\text{Both Positive}}) \\ &\quad = \frac{\piece{7.2}}{\piece{7.2} + 3.96} = \frac{\piece{7.20}}{\evidence{11.16}} \\ &\quad = \frac{20}{31} \approx 64.5\% \end{aligned}