Worked examples — Bayes' theorem — derivation and applications
This page is the workout floor for Bayes' theorem. The parent note built the formula; here we drill it against every kind of input a problem can hand you — normal cases, extreme priors, extreme tests, ties, degenerate zeros, and exam traps. If you can survive the whole matrix below, no Bayes question can surprise you.
Everything rests on one formula. We keep it in view the whole time:
Before we compute anything, let us decode the pieces once more in plain words, because every worked example refers to them by name.
The scenario matrix
Every Bayes problem is one row of this table. The examples that follow are labelled with the Cell they cover, so you can tick each one off.
| Cell | Scenario class | What is unusual about the inputs | Example |
|---|---|---|---|
| C1 | Standard rare-cause, 2 hypotheses | small prior, good test | Example 1 |
| C2 | High prior (common cause) | prior no longer tiny | Example 2 |
| C3 | Multi-way partition () | three or more mutually exclusive causes | Example 3 |
| C4 | Degenerate: perfect test () | a likelihood is exactly | Example 4 |
| C5 | Degenerate: prior or | belief already certain | Example 5 |
| C6 | Useless evidence (independence) | likelihoods equal → tells you nothing | Example 6 |
| C7 | Real-world word problem | you must extract the numbers yourself | Example 7 |
| C8 | Sequential updating (limiting behaviour) | posterior becomes next prior; watch the limit | Example 8 |
| C9 | Exam twist — asks for the complement or odds form | answer isn't the plain posterior | Example 9 |
Each cell exercises a distinct shape of input: signs of "rarity" (small vs large prior), degenerate corners (a probability equal to or ), a tie (independence), a limiting process (many updates), and the two ways exams disguise the question. Together they fill the whole space.
Two mental tools we lean on:
Example 1 — C1 · The standard rare-cause case
Step 1 — list prior and likelihoods. Why this step? We must separate how rare the allergy is (prior) from how the test behaves (likelihood) — the parent note's whole warning is that these are different things.
Step 2 — build the evidence as a head-count. Take children (look at the figure):

- Allergic: . Of these, test positive (blue).
- Not allergic: . Of these, test positive (orange false alarms).
Why this step? A positive can arise two ways (real or false alarm); the evidence must include both, or the posterior won't normalise — the third parent-note mistake.
Step 3 — apply Bayes (of all flagged, what fraction are real?). Why this step? Bayes is literally "true positives all positives" — the definition of conditional probability restricted to the positive column.
Verify: the two posteriors must sum to : , and . ✓ The answer sits far below — the rarity swamped the test, exactly as forecast if you guessed "under ".
Example 2 — C2 · A common cause (large prior)
Step 1 — new prior, same likelihoods. . Why this step? We are isolating the effect of the prior alone — the test is untouched.
Step 2 — evidence. Why this step? Same two-channel sum; only the group sizes shifted.
Step 3 — posterior. Why this step? Bayes engine, unchanged.
Verify: complement ; . ✓ The identical test went from trustworthy to trustworthy purely because the prior rose. This is the parent note's "prior and likelihood both matter."
Example 3 — C3 · Three-way partition
Step 1 — priors and likelihoods for all three causes. Why this step? With mutually exclusive and exhaustive sources, the partition has three cells; every one must appear in the evidence sum.
Step 2 — evidence (sum over all three). Why this step? Law of Total Probability with three terms — forgetting even one term corrupts the denominator.
Step 3 — posterior for spam. Why this step? The spam contribution dominates the tiny friend/work contributions.
Verify: all three posteriors sum to : . ✓ This is the seed of the Naive Bayes Classifier.
Example 4 — C4 · A perfect (degenerate) test
Step 1 — inputs, noting a likelihood is exactly . Why this step? A zero in the likelihood is a degenerate corner — it will annihilate a whole channel.
Step 2 — evidence. Why this step? The false-alarm channel vanishes because its likelihood is — no non-carrier can ever be flagged.
Step 3 — posterior. Why this step? When only carriers can ever test positive, a positive is proof. Notice even though — the two conditionals are genuinely different (the prosecutor's-fallacy lesson).
Verify: ; sums to . ✓ Degenerate but consistent — as long as we never divide by zero.
Example 5 — C5 · A certain prior ()
Step 1 — inputs, prior pinned at a corner. Why this step? is the other degenerate corner — belief is already certain. Both likelihoods were stated in the problem, so no symbol is used before it is defined.
Step 2 — evidence. Why this step? The disease channel is multiplied by a zero prior, so it contributes nothing.
Step 3 — posterior. Why this step? Bayes cannot resurrect a hypothesis you assigned probability . A zero prior is a permanent verdict; this is the danger of ever declaring a cause literally impossible.
Verify: numerator is , so posterior is for any positive test. ✓ Lesson: never set a prior to exactly or unless you truly mean "no evidence can ever change my mind."
Example 6 — C6 · Useless evidence (a tie → independence)
Step 1 — inputs, spotting equal likelihoods. Why this step? Equal likelihoods are the signature of evidence that discriminates nothing.
Step 2 — evidence.
Step 3 — posterior. Why this step? The posterior equals the prior, . When , the events are independent and — Bayes correctly refuses to update on irrelevant data.
Verify: exactly. ✓ This is the parent note's "special case where ."
Example 7 — C7 · Real-world word problem (extract the numbers)
Step 1 — translate words into symbols. Let = cab is Blue, = witness says "Blue". Why this step? The hardest part of a word problem is deciding which number is the prior and which is the likelihood. " accurate" is a likelihood (given the true colour); " Blue" is the prior.
Step 2 — evidence: how often does the witness ever say "Blue"? Use cabs (figure):

- Blue cabs: ; witness says "Blue" for .
- Green cabs: ; witness wrongly says "Blue" for .
Why this step? Many green cabs, even at a low error rate, produce many false "Blue" calls.
Step 3 — posterior. Why this step? The plentiful green cabs pull the answer well below the witness's accuracy.
Verify: complement ; . ✓ Under — base rates of green cabs matter, the classic base-rate-neglect trap.
Example 8 — C8 · Sequential updating & its limit
Step 1 — first red. Prior . Why this step? One draw updates the belief; the posterior now becomes the prior for the next draw — this is belief updating in action.
Step 2 — second red. New prior . Why this step? Chaining Bayes; because draws are independent, we may equivalently multiply likelihoods vs .
Step 3 — third red. New prior . Why this step? Third and final update in the chain; each red keeps pushing belief toward the Loaded bag.
Step 4 — the limit. After reds the odds are . Since , this , so Why this step? Evidence that consistently favours a hypothesis drives the posterior toward certainty — but never reaches in finite draws (unless a likelihood was exactly , cf. Example 4).
Verify: the compact odds formula must reproduce Step 3: . ✓ Matches the step-by-step chain.
Example 9 — C9 · Exam twist: complement & odds form
Step 1 — posterior odds via the odds form of Bayes. Why this step? The odds form sidesteps the evidence entirely — dividing the two Bayes equations cancels the common denominator.
Step 2 — recover the posterior to check (optional bridge). Why this step? Confirms the odds match Example 1's — the exam's "odds" answer is the same truth in a different costume.
Step 3 — the false-alarm probability is just the complement. Why this step? "Given a positive, what's the chance it's wrong?" is exactly minus the posterior — no new computation needed.
Verify: posterior odds nothing else should give back the fraction: , and . ✓
Scenario matrix — did we cover every cell?
Recall Tick the whole matrix
C1 standard rare cause ::: Example 1 () C2 large prior ::: Example 2 () C3 multi-way partition ::: Example 3 ( spam) C4 perfect test, a likelihood ::: Example 4 () C5 certain prior ::: Example 5 (, unmovable) C6 useless evidence / independence ::: Example 6 (posterior prior ) C7 real-world word problem ::: Example 7 (taxis, ) C8 sequential updating & limit ::: Example 8 (three reds → , limit ) C9 exam twist: odds & complement ::: Example 9 (odds , false alarm )
Connections
- Bayes' theorem — derivation and applications — the parent formula every example runs on.
- Conditional Probability — "of the flagged column, what fraction is real."
- Law of Total Probability — the multi-term evidence in Examples 3, 8.
- Independent Events — the tie in Example 6 ().
- Tree Diagrams — the crowd-splitting pictures in Examples 1 and 7.
- Prior and Posterior Distributions — sequential updating in Example 8.
- Naive Bayes Classifier — Example 3's spam filter, generalised.