4.9.24 · D3Probability Theory & Statistics

Worked examples — Bayesian statistics — prior, likelihood, posterior (intro)

2,949 words13 min readBack to topic

This page is the drill-ground for the parent topic. Every worked example is tagged with the cell of a scenario matrix it fills, so that after reading you will have seen every kind of case Bayes' theorem can throw at you: discrete and continuous, rare and common events, strong and weak priors, zero-data and infinite-data limits, and a couple of exam-style twists.

If a symbol appears that you don't recognise, we build it here — no assumed notation.


The scenario matrix

Think of every Bayes problem as living in one cell of this grid. The columns are what kind of unknown you have; the rows are the tricky feature that changes the answer's flavour.

Cell Feature being tested Example that hits it
A Discrete unknown, ordinary numbers Ex 1 — disease test
B Rare event (tiny prior swamps a good test) Ex 2 — very rare disease
C Sequential updating (posterior becomes next prior) Ex 3 — two tests in a row
D Continuous unknown, flat prior Ex 4 — coin, uniform prior
E Continuous unknown, informative prior Ex 5 — coin, Beta(a,b) prior
F Zero-data / degenerate limit Ex 6 — flip nothing, flip all-heads
G Large-data limit (data drowns the prior) Ex 7 — 700 heads in 1000
H Real-world word problem with a twist Ex 8 — spam filter
I Exam twist: prior odds & Bayes factor Ex 9 — odds form

Every numeric answer below is machine-checked in the verify block.


Before we start, two words we will use constantly:


Cell A — Discrete unknown, ordinary numbers

Only ~17% — the base rate crushes the " test" gut guess. There are simply far more healthy people to generate false positives.


Cell B — Rare event (tiny prior swamps a good test)

Figure — Bayesian statistics — prior, likelihood, posterior (intro)

Cell C — Sequential updating (posterior becomes the next prior)

A single positive left us at ; a second independent positive vaults us to ~80%. Accumulating evidence, done honestly.


Cell D — Continuous unknown, flat prior

Figure — Bayesian statistics — prior, likelihood, posterior (intro)

Cell E — Continuous unknown, informative prior

Figure — Bayesian statistics — prior, likelihood, posterior (intro)

Cell F — Zero-data and degenerate limits


Cell G — Large-data limit (data drowns the prior)


Cell H — Real-world word problem (twist)


Cell I — Exam twist: odds form & Bayes factor


Recall Which cell am I in? (self-test — reveal after guessing)

"Rare disease, one positive test" ::: Cell A/B — discrete, base-rate dominated. "I already updated once and got more data" ::: Cell C — posterior becomes the new prior. "Coin bias with no strong opinion beforehand" ::: Cell D — continuous, flat Beta(1,1). "Coin bias but I truly believe it's near fair" ::: Cell E — informative Beta prior. "I have thousands of observations" ::: Cell G — data drowns the prior, converges to MLE. "I only need to compare two hypotheses fast" ::: Cell I — odds form, evidence cancels.