1.3.3 · D4Probability & Statistics

Exercises — Bayes' theorem and applications

2,531 words12 min readBack to topic

A picture of what the formula is doing — it splits a population into four boxes and asks "of the two positive boxes, what fraction is the true one?"

Figure — Bayes' theorem and applications

Level 1 — Recognition

(Can you name the pieces and plug in? No traps yet — just fluency.)

Recall Solution 1.1
  • — the prior, the base rate of defective chips.
  • — the likelihood: flagged given truly defective.
  • — the false-alarm rate: flagged given good. Also . That is all Level 1 asks: matching English sentences to symbols.
Recall Solution 1.2

— the probability the chip is actually defective given that the scanner flagged it. This is the posterior. The manager does not care how often the scanner fires on bad chips (); they care whether this flagged chip is truly bad.


Level 2 — Application

(Now run the full machine and get a number.)

Recall Solution 2.1

WHAT we do: plug into the expanded Bayes formula. WHY: we are never told directly, so we build it from the two ways a chip can be flagged. Top (true positives): . False positives: . Answer: about 41%. Even a fairly sharp scanner leaves real doubt, because good chips vastly outnumber bad ones, so their 4% false alarms pile up.

Recall Solution 2.2

= spam, = contains "lottery". , , , . Answer: about 92.8%. A word that is 30× rarer in ham than spam ( vs ) is powerful evidence. See 2.1.05-Naive-Bayes-classifier for how many such words get multiplied together.

Recall Solution 2.3

WHY odds form? It skips the denominator entirely — handy when you only need to compare, or when chaining evidence.

  • Prior odds .
  • Likelihood ratio .
  • Posterior odds . Convert odds back to probability with : Same 92.8% — the two roads meet.

Level 3 — Analysis

(Explain why the number behaves as it does; probe sensitivity.)

Recall Solution 3.1

WHAT we do: Bayesian updating — the posterior after test 1 becomes the prior for test 2. WHY: independent evidence multiplies; the odds form makes this clean.

  • Prior odds .
  • Likelihood ratio per positive scan .
  • Two positive scans: multiply the ratio twice. Answer: about 94.0%. One flag left us at 41%; a second independent flag rockets us to 94%. WHY: each 22.5× likelihood ratio is strong, and stacking two overpowers the rare prior. This is exactly point 3 ("update incrementally") in the parent's "Why Bayes is powerful."
Recall Solution 3.2

Setup: posterior means true-positive mass equals false-positive mass. WHY this equation: at 50% posterior the two boxes in the denominator are equal, so their numerators must match. Answer: a 5% base rate. Below 5% prevalence, a single positive is more likely wrong than right; above it, more likely right. This one number explains the whole "base-rate fallacy": the test's usefulness hinges on how common the disease already is.


Level 4 — Synthesis

(Combine several tools: total probability, multiple hypotheses, and independence.)

Recall Solution 4.1

WHAT: three mutually exclusive hypotheses, so use the extended Bayes (denominator = sum over all suppliers). WHY: the bulb came from exactly one supplier; they partition the sample space. Numerators :

  • A:
  • B:
  • C: Total (evidence) . Posteriors: Answer: supplier C, with ≈ 47.6%. Though C makes only 20% of bulbs, its high defect rate makes it the top suspect. Notice the three posteriors sum to 1 — the denominator's job.

The bar chart below shows how the small supplier C wins the "defective" verdict despite the smallest share of production:

Figure — Bayes' theorem and applications
Recall Solution 4.2

WHY multiply: the naive assumption says both words' likelihoods multiply within each class.

  • Spam numerator: .
  • Ham numerator: . Answer: about 98.2%. Two independent spammy words compound: each multiplies the odds, so evidence stacks fast — the same mechanism as repeated tests in Exercise 3.1.

Level 5 — Mastery

(Invent, defend, and reason about the model itself.)

Recall Solution 5.1

A test carries no information when a positive is equally likely under and : Then the likelihood ratio is , posterior odds = prior odds, and the posterior equals the prior — the test taught us nothing. If instead , the likelihood ratio is below 1, and a positive result lowers your belief. Example: sensitivity but gives ratio , so a "positive" is actually mild evidence against disease. Lesson: high sensitivity alone means nothing; the ratio of the two likelihoods is what moves belief.

Recall Solution 5.2

Let prior odds and . After tests, odds . Since , as , so odds , and . So in principle enough independent positives overwhelm any prior. The catch: real repeated tests are not independent — the same underlying flaw (a cross-reacting antibody, a scanner biased by chip material) makes a false positive recur, so collapses toward 1 on repeats. The mathematics is sound; the independence assumption is the fragile part — the very lesson of Mistake 3 on treating independence as truth. Compare with the frequentist stance in 3.4.01-Maximum-likelihood-estimation, which drops priors entirely, and the fuller machinery in 4.2.03-Bayesian-inference.