Prob and StatsProbability Rules

Bayes' Rule

Reverse a conditional probability with a tree or a table.

Not started Jump to practice

A medical test is "90% accurate," and you test positive. How likely is it that you have the condition? Most people guess about 90%. The right answer is often far lower. Bayes' rule reverses a conditional probability, using the multiplication rule and the table idea together.

Key idea

To reverse a conditional probability, imagine a large group (say 10,000 people) and count. In symbols, $$P(D \mid +) = \dfrac{P(D)\,P(+ \mid D)}{P(D)\,P(+ \mid D) + P(D^{\prime})\,P(+ \mid D^{\prime})}.$$ The answer depends heavily on the base rate $P(D)$.

Why it works

By definition, $P(D \mid +) = P(D \cap +)/P(+)$. The multiplication rule gives the numerator: $P(D \cap +) = P(D)P(+ \mid D)$. A positive test happens in two ways, a true positive or a false positive, so $P(+)$ is the sum of the two paths in the tree (the law of total probability). When the condition is rare, the healthy group is huge, and even a small false-positive rate applied to it produces more positives than the small sick group does.
Each square is one person. Red: has the condition. Gold: a false alarm. Slide the base rate up and watch the share of real positives grow.

Worked example: Natural frequencies

A condition affects 1% of people. A test is positive for 90% of people who have it and for 9% of people who do not. You test positive. Find $P(\text{condition} \mid +)$.
  1. Imagine 10,000 people: 100 have the condition, 9,900 do not.
  2. True positives: 90% of 100 = 90.
  3. False positives: 9% of 9,900 = 891.
  4. Positives in all: $90 + 891 = 981$. Of these, 90 have the condition.
  5. $$P(\text{condition} \mid +) = \dfrac{90}{981} \approx 0.092$$

Answer: About 9%, not 90%.

Worked example: The same answer with the formula

Check the result with Bayes' rule.
  1. Numerator: $$P(D)P(+ \mid D) = 0.01 \times 0.9 = 0.009$$
  2. Denominator: $$0.009 + P(D^{\prime})P(+ \mid D^{\prime}) = 0.009 + 0.99 \times 0.09 = 0.009 + 0.0891 = 0.0981$$
  3. $\dfrac{0.009}{0.0981} \approx 0.092$.

Answer: About $0.092$.

Worked example: A second positive test

A person who tested positive takes a second, independent test of the same kind, and it is positive too. Now what is the probability of the condition?
  1. After the first test, the person's probability is $\frac{90}{981} \approx 9.2\%$: that is the new base rate.
  2. Imagine 981 such people: 90 have it, 891 do not.
  3. Second test: true positives $0.9 \times 90 = 81$; false positives $0.09 \times 891 = 80.19$.
  4. $P = \dfrac{81}{81 + 80.19} \approx 0.50$.

Answer: About 50%: each positive test raises the probability, starting from the base rate.

The condition is "Positive" on either path. P(condition | positive) = the selected path divided by both positive paths.

Common mistake

Ignoring how rare the condition is and trusting a positive result too much: treating $P(+ \mid D) = 90\%$ as if it were $P(D \mid +)$. Check by imagining 10,000 people and counting both kinds of positives. If the healthy group is huge, false positives can outnumber true ones.

Practice

Pass with 3 right answers, the last 2 in a row. Each right answer earns 3 XP.

Loading practice…

Builds on

Leads to

Sources and further reading

  • OpenStax, Introductory Statistics 2e, section 3.5 Tree and Venn Diagrams
  • MIT OpenCourseWare, 18.05 Introduction to Probability and Statistics (Spring 2014): Class 3, Conditional Probability, Independence and Bayes' Theorem
@teddyrookbook GitHub