MathPath
Grades 1–13 Math Hub
Grades 11–13 · AP Statistics & Probability · Formula Deep Dive

Bayes' Theorem: Probability Tree, Proof & Examples

Bayes' Theorem reverses a conditional probability—updating your initial belief (prior $P(A)$) into a revised belief (posterior $P(A \mid B)$) after observing new evidence $B$.

$$P(A \mid B) = \frac{P(B \mid A)P(A)}{P(B)}$$

Variables: Updates prior probability $P(A)$ given new evidence $B$.

When to use: Medical test accuracy, spam filters, and reverse conditional probability.

Probability Tree for Bayes' Theorem

P(A)P(A')P(B|A)P(B|A')A ∩ BA ∩ B'A' ∩ BA' ∩ B'

Two coral paths end in evidence $B$: the true-positive branch $A \cap B$ and the false-positive branch $A' \cap B$. Bayes' Theorem divides the top coral branch by the sum of BOTH coral branches.

Two-Line Derivation from Conditional Probability

Write the intersection $P(A \cap B)$ in two symmetric ways using the multiplication rule.

  1. By conditional probability, $P(A \cap B) = P(A \mid B)P(B)$ and also $P(A \cap B) = P(B \mid A)P(A)$.
  2. Set them equal: $P(A \mid B)P(B) = P(B \mid A)P(A)$.
  3. Divide by $P(B)$: $P(A \mid B) = \frac{P(B \mid A)P(A)}{P(B)}$.
  4. Expand $P(B)$ using the Law of Total Probability: $P(B) = P(B \mid A)P(A) + P(B \mid A')P(A')$.

The 4 Pieces of Bayes' Theorem

Prior $P(A)$

Initial probability of hypothesis $A$ BEFORE seeing the evidence.

Likelihood $P(B \mid A)$

Probability of observing evidence $B$ if hypothesis $A$ is true (e.g., test sensitivity).

Total Evidence $P(B)$

Sum of ALL ways $B$ can happen: $P(B \mid A)P(A) + P(B \mid A')P(A')$.

Posterior $P(A \mid B)$

Updated probability of $A$ AFTER observing evidence $B$.

Step-by-Step Worked Examples

Example 1: The Classic Medical Screening Paradox

Problem: A condition affects $1\%$ of people ($P(D) = 0.01$). A test has $99\%$ sensitivity ($P(+ \mid D) = 0.99$) and a $5\%$ false-positive rate ($P(+ \mid D') = 0.05$). If someone tests positive, what is $P(D \mid +)$?
  1. True-positive branch: $P(+ \mid D)P(D) = 0.99 \times 0.01 = 0.0099$.
  2. False-positive branch: $P(+ \mid D')P(D') = 0.05 \times 0.99 = 0.0495$.
  3. Total positive probability: $P(+) = 0.0099 + 0.0495 = 0.0594$.
  4. Posterior: $P(D \mid +) = \frac{0.0099}{0.0594} = \frac{1}{6} \approx 16.7\%$ — far lower than $99\%$ because the condition is rare!

Example 2: Two Factories Quality Control

Problem: Factory A makes $60\%$ of phones ($2\%$ defective); Factory B makes $40\%$ ($5\%$ defective). A random phone is defective—what is the probability it came from Factory B?
  1. Branch A defective: $0.60 \times 0.02 = 0.012$. Branch B defective: $0.40 \times 0.05 = 0.020$.
  2. Total defective: $P(\text{Def}) = 0.012 + 0.020 = 0.032$.
  3. Apply Bayes: $P(B \mid \text{Def}) = \frac{0.020}{0.032} = 0.625$ ($62.5\%$).

Common Mistakes to Avoid

Mistake 1: Base-Rate Fallacy: Confusing $P(A \mid B)$ with $P(B \mid A)$

✗ Wrong: Assuming a $99\%$ accurate test means a positive result has a $99\%$ chance of disease.
✓ Correct: Always weight by the prior $P(A)$ and include false positives from the healthy majority $P(A')$.

Why: When $A$ is rare, even a small false-positive rate on the huge $A'$ group can outnumber true positives.

Mistake 2: Forgetting the Second Term in $P(B)$

✗ Wrong: Using only $P(B \mid A)P(A)$ in the denominator (which always gives $1$).
✓ Correct: Include EVERY branch that leads to $B$: $P(B \mid A)P(A) + P(B \mid A')P(A')$.

Why: Drawing a quick 2-level tree diagram makes both branches impossible to miss.

Frequently Asked Questions

When should I draw a probability tree vs. a two-way table?

Both work! For quick mental intuition, imagine $10{,}000$ people in a $2 \times 2$ table—you'll get the exact same Bayes ratio without memorizing letters.

What if there are 3 or more hypotheses ($A_1, A_2, A_3$)?

Just sum all $k$ branches in the denominator: $P(B) = \sum_{i=1}^k P(B \mid A_i)P(A_i)$.

Where is Bayes' Theorem used in real life?

Medical diagnostics, email spam filters, machine learning classifiers, A/B testing, and forensic statistics.

Practice & Related Resources

Apply Bayes' Theorem on interactive problems, printable PDF worksheets, and calculators.

Addition & Conditional Probability Rules →All Statistics & Probability Formulas →Percentage Calculator →Grade 13 Stats Quizzes → ← Back to Statistics Formulas Cheat Sheet