Exercises — Bayes' theorem — derivation and applications
Level 1 — Recognition
Here you only have to spot which quantity is which. No hard arithmetic — the goal is to never again confuse "given the cause" with "given the evidence".
Exercise 1.1
A weather app says: "When it actually rains, the app has forecast rain of the time." In symbols, with "it rains" and "app forecasts rain", which conditional probability is : or ?
Recall Solution 1.1
The sentence fixes the actual weather first ("when it actually rains") and then reports how the app behaves. So the given (the condition, the thing after the bar) is . That makes it This is a likelihood — probability of the evidence (forecast) given the cause (rain). The quantity a user actually wants, "it forecast rain, so how likely is real rain?", is the reversed one , and Bayes is what connects them.
Exercise 1.2
In the disease-test setting, match each phrase to its symbol: (a) " of people have the disease", (b) "the test is sensitive", (c) "you tested positive; are you sick?". Use = disease, = positive test.
Recall Solution 1.2
- (a) is the prior — belief before any test.
- (b) is the likelihood — how the test behaves given you are sick (sensitivity is a "true-positive rate").
- (c) is the posterior — the updated belief after seeing the positive. This is the unknown Bayes computes.
Exercise 1.3
Two bags partition all your marbles: bag (red) and bag (blue), with , . Without any evidence yet, do these two priors have to add to ? Why?
Recall Solution 1.3
Yes: . A partition means the causes are mutually exclusive (a marble is in exactly one bag) and exhaustive (there are no other bags). Every marble is accounted for exactly once, so the priors must sum to . If they did not, the denominator in Bayes could never normalise the posteriors to .
Level 2 — Application
Now you plug numbers into the formula, using the tree structure to organise the joints.
Exercise 2.1
A factory line: of items are Type-A, are Type-B. Type-A passes inspection with probability ; Type-B passes with probability . An item passes. Find .
Recall Solution 2.1
Priors: . Likelihoods: .
Evidence (Law of Total Probability — a pass can come from A or B): Bayes: The posterior () barely rises above the prior () — passing is only mild evidence of being Type-A because Type-A items pass almost as easily as Type-B.
Exercise 2.2
Reuse Exercise 2.1's numbers but the item fails. Find .
Recall Solution 2.2
Fail likelihoods are the complements: , .
Evidence: (Check: , so passes and fails partition all items.)
Bayes: A failure is strong evidence of Type-B: even though only of items are Type-B, they fail eight times as often, so they dominate the failures.
Exercise 2.3
Redo Worked Example 1 of the parent note but with a more specific test: , (specificity ), prevalence . Find .
Recall Solution 2.3
Cutting the false-positive rate from to lifts the posterior from (parent note) to exactly . Specificity, not just sensitivity, is what tames false positives on a rare disease.
Level 3 — Analysis
Here you juggle a partition of three or more causes, or reason about how the answer moves.
Exercise 3.1
Three factories supply chips: X (, defect rate ), Y (, defect rate ), Z (, defect rate ). A chip is defective. Find the posterior probability it came from each factory, and name the most likely source.
Recall Solution 3.1
Joints : Evidence: Posteriors: They sum to (good). Despite making the fewest chips, Z is the most likely source of a defect because its defect rate is four times X's. See the figure: the prior bars (widths) shrink toward the posterior once we weight by defect rate.

Exercise 3.2
In Exercise 3.1, without recomputing, decide: if Factory Z's defect rate halved to , would go up or down? Then verify.
Recall Solution 3.2
Reasoning first: halving Z's defect rate shrinks Z's joint from to , while X and Y are unchanged. A smaller numerator with a smaller total pulls Z's share down.
Verify: new joints ; evidence . down from . Y now becomes the leader (). The most likely cause is not fixed — it tracks the product of prior and likelihood.
Exercise 3.3
A spam filter: of email is spam. The word "free" appears in of spam and of ham (non-spam). An email contains "free". Find , then say what fraction of emails containing "free" are actually ham.
Recall Solution 3.3
Priors: . Likelihoods: . The ham fraction is the complement, . This "one word, one update" step is exactly the atom of a Naive Bayes Classifier, which multiplies many such word-updates together.
Level 4 — Synthesis
Now you combine Bayes with a second idea: repeated evidence, complementary reasoning, or Independent Events.
Exercise 4.1
Same rare disease as parent note: , , . You test positive twice, and the two tests are conditionally independent given your true state. Find .
Recall Solution 4.1
Conditional independence means, given a fixed true state, the two results multiply: Evidence: Bayes: One positive gave only ; a second independent positive rockets it to . Bayes chains: the posterior after test 1 becomes the prior for test 2.
(Cross-check the chaining view: after test 1, prior . Then — same answer.)
Exercise 4.2
A box has two coins: a fair one () and a two-headed one (), chosen with equal prior. You draw a coin, flip it, and get heads. Find . Then find the probability the next flip of that same coin is heads.
Recall Solution 4.2
Priors: each coin . Likelihoods: . Next flip — mix the two coins by their posterior weights: Seeing one head made you lean toward the two-headed coin, which raises the expected chance of the next head above .
Exercise 4.3
A student either studied (prior ) or guessed (prior ). A studier answers a -option question correctly with probability ; a guesser gets it right by pure chance, . The student answers correctly. Find .
Recall Solution 4.3
Guess likelihood: . A correct answer nudges belief in studying from up to — evidence, but not certainty, because guessers occasionally get lucky.
Level 5 — Mastery
Full modelling: you build the partition, the likelihoods, and interpret the result — no scaffolding.
Exercise 5.1
An urn holds red and blue balls. You draw two balls without replacement. Given that the second ball is red, find the probability the first ball was red. (Order matters; use the two causes "first red" / "first blue" as your partition.)
Recall Solution 5.1
Priors (colour of first draw): . Likelihoods for "second is red", now with one ball removed: Evidence: (Sanity: by symmetry the marginal chance any specific draw is red equals the overall red fraction — reassuring.) Bayes: Knowing the second ball is red makes the first slightly less likely to have been red than its prior — because a red first draw leaves fewer reds for the second.
Exercise 5.2
A signal source sends bit with prior and bit with prior . A noisy channel flips a bit with probability (independent of which bit). You receive a . What was most likely sent, and with what posterior probability?
Recall Solution 5.2
Likelihoods of receiving : if was sent, no flip: ; if was sent, a flip is needed: . Most likely was sent, posterior . The receiver's optimal decision uses both the prior bit-frequency and the channel reliability — this is the core of Bayesian decoding.
Exercise 5.3
Bag : of balls are green. Bag : green. You pick a bag at random ( each), draw with replacement, and observe the sequence green, green, red. Which bag is more likely, and give .
Recall Solution 5.3
With replacement, draws are independent given the bag, so likelihoods multiply. Evidence: Bayes: Bag is more likely (). Two greens pull toward the greener bag ; the single red pulls back a little, but not enough to overturn it.
Recall One-line self-test before you leave
Every problem above followed the same skeleton — recite it. ::: List priors ; list matching likelihoods ; sum the products to get evidence ; divide the one joint you want by . "PLE over E."
Connections
- Bayes' theorem — derivation and applications — the parent note these exercises drill.
- Conditional Probability — the definition every step rests on.
- Law of Total Probability — builds the evidence denominator in every solution.
- Independent Events — used to multiply likelihoods in L4/L5.
- Tree Diagrams — the bookkeeping picture behind the joints.
- Naive Bayes Classifier — the spam problem (3.3) scaled up.
- Prior and Posterior Distributions — where chained updates (4.1) generalise.