Total Probability and Bayes' Theorem
The law of total probability, Bayes' theorem with priors, likelihoods and posteriors, tree diagrams, the odds form and likelihood ratios, the base-rate fallacy, sequential updating, and the MAP/ML decision rules that machine learning builds on.
The law of total probability
Let be a partition of the sample space (disjoint, exhaustive, each with positive probability). Then for any event ,
Think of it as "average the conditional probabilities, weighted by how likely each scenario is". The continuous version replaces the sum by an integral: .
Bayes' theorem
Combining the definition of conditional probability with total probability:
| Term | Name | Meaning |
|---|---|---|
| prior | belief in hypothesis before seeing evidence | |
| likelihood | how probable the evidence is if is true | |
| evidence / marginal likelihood | normalising constant | |
| posterior | updated belief after seeing |
The base-rate fallacy
When the prior is tiny, even an accurate test produces mostly false positives. In the tree above, the 0.0495 false-positive mass is five times the 0.0095 true-positive mass. Medical screening, fraud detection and spam filtering all face this: the precision of a detector depends on the base rate, while its recall (sensitivity) does not.
| Test quantity | Definition |
|---|---|
| Sensitivity (recall, TPR) | |
| Specificity (TNR) | |
| False-positive rate | |
| Positive predictive value (precision) | — needs the prior |
Odds form and likelihood ratios
Odds . Bayes' theorem becomes
With conditionally independent pieces of evidence , the likelihood ratios multiply — fast for repeated tests. Convert back with .
Sequential updating
Today's posterior is tomorrow's prior. Updating on then gives the same result as updating on both at once, provided you use in the second step (which equals under conditional independence).
Decision rules: MAP and ML
To pick one hypothesis after seeing evidence :
- Maximum a posteriori (MAP): choose (the evidence does not depend on ).
- Maximum likelihood (ML): choose — MAP with a uniform prior.
The Bayes classifier (MAP) minimises the probability of misclassification. Naive Bayes and LDA are MAP classifiers with particular likelihood models.
Quick revision
Practice questions
GATE-style questions: 2 one-mark and 7 two-mark. Wrong MCQs cost ⅓ of their marks in the real exam; MSQ and NAT have no negative marking. Attempt each before opening the solution.
A disease affects 1% of a population. A test detects the disease with probability 0.95 when it is present and gives a false positive with probability 0.05 when it is absent. A randomly chosen person tests positive. The probability that the person has the disease is ______ (round to two decimals).
Machines A, B and C produce 50%, 30% and 20% of a factory's output, with defect rates 2%, 3% and 5% respectively. An item chosen at random is defective. The probability that it was produced by machine A is ______ (round to two decimals).
In Bayes' theorem , the term is called the
Urn 1 contains 3 red and 2 blue balls; urn 2 contains 1 red and 4 blue balls. A fair coin decides which urn to draw from, and one ball is drawn. It is red. The probability that it came from urn 1 is ______.
In the Monty Hall game, a car is behind one of three doors. You pick door 1. The host, who knows where the car is and always opens a goat door you did not pick (choosing at random when he has a choice), opens door 3. The probability that you win the car by switching to door 2 is ______ (round to two decimals).
A disease has prevalence 1%; a test has sensitivity 0.95 and false-positive rate 0.05. A person tests positive on two independent tests (conditionally independent given disease status). The probability of disease is closest to
If , and , then is ______.
For events with and , which of the following always hold?
One or more options are correct.
In a multiple-choice exam with 4 options per question, a student knows the answer with probability 0.6 and otherwise guesses uniformly at random. Given that the student answered a question correctly, the probability that the student actually knew the answer is ______ (round to two decimals).