Probability, conditional probability and Bayes' rule
Before this lesson: nothing from this track; this is the first lesson. You need sets and their notation: union , intersection , complement , the empty set (foundations, lesson 2). A gentle start with chance and data is foundations, lesson 8 (optional). Time: about 80 minutes, plus the notebook.
Why this matters #
Every probabilistic model in machine learning is built from the rules of this lesson. A posterior over parameters, , is Bayes' rule (lesson 10). A naive Bayes spam filter multiplies likelihood ratios, which is correct only under conditional independence. Hidden Markov models, Bayesian networks and the forward process of a diffusion model are lists of conditional independences.
The base-rate effect explains why a fraud detector with 99% recall can still produce mostly false alarms, and why many "significant" A/B test results are not real effects. Questions about Bayes' rule and the Monty Hall problem are also among the first questions in data science and ML interviews.
1. Predict first #
2. The picture #
Outcomes, events and counting #
Roll a fair die. The sample space is the set of all possible outcomes. An event is a subset of , for example "even" . We say that the event happens when the outcome lies in it.
When all outcomes are equally likely and is finite,
So . For two dice, has equally likely ordered pairs . The sum is 7 for , so .
Counting gets hard quickly, so here are three tools.
- Multiplication rule. If a choice has options and, for each of them, a second choice has options, there are pairs. Two dice: .
- Permutations (ordered, no repetition). The number of ordered lists of different items taken from is . With this is , the number of orders of items: 3 books can stand on a shelf in orders.
- Combinations (unordered). The number of -element subsets of an -element set is . Each subset appears in orders among the permutations, so we divide by . Example: in 4 fair coin flips, there are equally likely sequences, and of them have exactly 2 heads. So .
The birthday problem. Assume 365 equally likely birthdays, independent between people (ignore 29 February and twins). Among people, count the outcomes with no shared birthday: the first person has 365 options, the second 364, and so on. So
For this gives . The number is large because there are pairs of people, and each pair is a chance for a match. This trick, "compute the complement", is often the easiest path.
Probability as mass. In general, outcomes need not be equally likely. Think of probability as mass spread over , with total mass 1. is the mass inside . There is also a frequency view: if you repeat the experiment many times, the share of repetitions in which happens gets close to . Roll a die 10,000 times and about 1/6 of the rolls show a 6 (the notebook does it). Lesson 06 proves this as the law of large numbers.
Conditioning: zoom in and rescale #
You learn that the outcome lies in an event . Then the outcomes outside are no longer possible. The new probability of is the share of 's mass that also lies in :
Read as "the probability of given ". For the die: given "even", each of 2, 4, 6 has probability , and .
Press "Condition on B". Everything outside B (blue) fades, and is stretched to fill the whole square: it is the new sample space. The share of the new square covered by (aqua) is . Compare it with the share of the old square covered by A (violet), which is . Then drag the corner dots, and try the presets: in "independent", covers the same share of as of . In "disjoint", .
Independence as a picture. If covers the same share of as of the whole square, then learning does not change the chance of : . Then . This is independence; section 3 defines it precisely.
You roll a fair die and learn that the result is even. What is the probability that it is at least 5?
Given "even", the sample space shrinks to , three equally likely outcomes. Only is at least 5, so . Formally, . The last option divides by ; you must divide the probability of the intersection, .
Bayes' rule with counts #
Now the question from section 1. Imagine 10,000 people. This is the method of natural frequencies: replace probabilities by counts of people, and Bayes' rule becomes a division.
- 1% are sick: 100 sick and 9,900 healthy people.
- The test is positive for 90% of the sick: 90 true positives (10 sick people are missed).
- The test is negative for 91% of the healthy, so positive for 9%: 891 false positives.
In total people test positive, and only 90 of them are sick:
About 9%, not 90%. The test is good, but the disease is rare: the small error rate of 9% acts on a very large group (9,900 healthy people) and produces many more false alarms than there are sick people.
First set your guess, then press "Test everyone". Each small square is one of 10,000 people. Aqua squares are sick people who test positive; faint aqua squares are sick people the test misses. Magenta squares are healthy people with a positive test (false alarms). is the aqua count divided by aqua plus magenta. Raise the prevalence to 20% and watch the answer change, with the same test. Then press "Second test": only the positives are tested again.
The second test shows the power of more evidence. Of the 90 sick positives, 90% (81) test positive again. Of the 891 healthy positives, only 9% (about 80) do. Now . This assumes that the second test makes its errors independently of the first one, given the true state; section 3 makes this precise.
A news article says: "A new AI tool detects 95% of cancers in screening images, so a positive result means a 95% chance of cancer." What is wrong with this sentence?
95% is the sensitivity, . The probability a patient wants, , comes from Bayes' rule and needs the base rate and the false-positive rate. When cancer is rare in the screened group, most positives can be false alarms. The third option uses a rule that does not exist: conditioning cannot be reversed by taking a complement.
3. Definitions and main results #
The axioms of probability #
A probability space has three parts: a sample space , a collection of events (subsets of ), and a function that gives each event a number. Kolmogorov's axioms are:
- for every event .
- .
- Countable additivity: if are pairwise disjoint ( for ), then .
Everything else in probability follows from these three rules.
Why is not always "all subsets"
For a finite you can take = all subsets. For , there is no way to give every subset a probability such that the axioms hold, every interval has , and a shift of a set (modulo 1) keeps its probability: Vitali's construction gives a set that breaks it. So is a σ-algebra: a collection that contains and is closed under complements and countable unions. All sets you meet in practice (intervals, their unions, sets defined by continuous functions) are in it. In this track, read "event" as "a set you are allowed to ask about".
Derived rules. Let be events.
- . The sets are pairwise disjoint and their union is . Axiom 3 gives . A sum of equal nonnegative numbers is 0 only if each one is 0.
- Finite additivity. For disjoint , add empty sets and use axiom 3 and rule 1: .
- Complement rule . and are disjoint, and their union is . So .
- Monotonicity. If , then . Write , a disjoint union, so . In particular, .
- Inclusion–exclusion . Write and ; both are disjoint unions. So and . Substitute the second equation into the first.
The term is subtracted because counts the overlap twice.
Union bound (Boole's inequality). , so rule 5 gives . By induction on ,
It needs no assumption about the events. It is the main tool when many things can go wrong at the same time: many tests in a study (lesson 11), many hypotheses in a learning bound (lesson 07).
Conditional probability, trees and the law of total probability #
Definition. For , the conditional probability of given is .
For a fixed , the function satisfies all three axioms (check: it is ; ; and disjoint give disjoint ). So every rule of this lesson also holds with "" added everywhere, for example .
Multiplication rule. Multiply the definition by : . Repeated, it gives the chain rule .
Probability trees. A tree draws the chain rule. Each branch carries a conditional probability, and the probability of a path is the product along it. Example: draw two cards from a 52-card deck without putting the first back. Write = "first card is an ace", = "second card is an ace".
The event is reached by two paths, so add them: . This is exactly : before you look at the first card, the second card is an ace with the same chance as the first. Adding the paths is the next theorem.
Theorem (law of total probability). Let be a partition of (pairwise disjoint, with union ) with all . Then
Proof.
- , because the cover .
- The sets are pairwise disjoint, because the are.
- Finite additivity gives .
- The multiplication rule gives .
In the medical test, the partition is {sick, healthy}, and : the 981 positives out of 10,000.
Bayes' rule #
Theorem (Bayes' rule). Let and . Then
If also , the denominator is . More generally, for a partition : .
Proof. Both and equal , by the multiplication rule. Divide by . The denominator is the law of total probability.
Write for a hypothesis (sick, fraud, spam) and for the evidence (a positive test, a flag, a word in an e-mail). The parts of Bayes' rule have standard names:
The prior is what you believe before you see . The likelihood says how well predicts . The posterior is the updated belief. For a test, the standard words are: sensitivity (or recall, true positive rate) , specificity , false positive rate , prevalence (base rate) , and precision (positive predictive value) .
The base-rate fallacy is to read as if it were . When the prior is small, most positives come from the large group , even when the false positive rate is small.
Odds and likelihood ratios #
The odds of an event are . Probability 0.5 is odds 1 ("1 to 1"); probability 0.01 is odds . Write Bayes' rule for and for , and divide. The evidence cancels:
The likelihood ratio (LR, also called the Bayes factor) measures the strength of the evidence. For a positive test, . For the medical test, . The prior odds are , so the posterior odds are , and , as with the counts. A negative test has .
Take logarithms and the product becomes a sum: each piece of evidence adds to the log-odds. Strong evidence is a long step; useless evidence () is no step.
Two tests. Suppose two results are conditionally independent given and given (defined below): , and the same given . Then the likelihood ratio of both results is the product of the two likelihood ratios. Equivalently: update with , and use that posterior as the prior for . Two positive medical tests: posterior odds , so .
Add test results with + and −. The axis is the log-odds, with probabilities written on top. The violet dot is the prior. Each aqua arrow is one update: every independent positive is a step of the same length, , to the right. Now raise the dependence : with probability the second test only copies the first (same blood sample, same cable). Repeated results then carry less evidence. The magenta dashed track is the naive update that still multiplies the full likelihood ratios, so it counts the same evidence twice.
When the product rule fails. Two tests on the same blood sample, two sensors on the same cable, or two runs of the same model are not conditionally independent. If the second test always repeats the first one, then : the second result has likelihood ratio 1 and adds nothing.
Independence: three kinds #
- and are independent if . If , this is the same as . (The product form also works when , and it is symmetric in , .)
- are mutually independent if for every subset of the indices. For three events: the three pair conditions and .
- They are pairwise independent if only the pair conditions hold.
- and are conditionally independent given (with ) if .
Disjoint is not independent. If and , then . Disjoint events are strongly dependent: if happens, cannot.
Mutual independence implies pairwise independence. Every other implication fails:
| Gap | Counterexample |
|---|---|
| pairwise mutual | are independent fair coins with values 0/1, and (XOR: when exactly one of them is 1). The 4 outcomes are equally likely. Each pair takes its 4 values with probability , so every pair is independent. But . |
| conditional unconditional | A common cause. Two students take an exam that is easy () or hard (). Each student fails with probability 0.1 on an easy exam and 0.6 on a hard one, independently given the difficulty. Then , but . |
| unconditional conditional | A collider (common effect). Two independent servers each fail with probability 0.1. An alarm rings if at least one fails. Given the alarm, learning that server 2 failed makes a failure of server 1 less likely: drops to (explaining away; check-yourself question 5). |
In the common-cause example, , much more than 0.25. A failing student 1 is evidence for a hard exam, and a hard exam raises the chance that student 2 fails.
Events , , are pairwise independent, each with probability . Which statement must be true?
Pairwise independence gives only the three pair conditions, so . The XOR example (: , : , : ) breaks the other three: , and given the event is impossible, so .
Four classic traps #
1. The base-rate fallacy and the prosecutor's fallacy. . In court, "the chance of this evidence if the defendant is innocent is 1 in a million" is . It is not the chance that the defendant is innocent. In a city of 10 million people, about 10 innocent people would also match the evidence.
2. The Monty Hall problem. You pick door 1. The host knows where the car is. He always opens a door that you did not pick and that hides a goat (if he has two such doors, he picks one at random). He opens door 3. Let = "the car is behind door ", with prior each, and = "the host opens door 3". The likelihoods follow from the host's rule:
- : the car is behind your door, so both other doors hide goats;
- : he cannot open your door or the car's door;
- : he never shows the car.
Total probability: . Bayes' rule:
Switching wins with probability 2/3. The host's action carries information because it depends on where the car is. Your own door keeps its prior 1/3: the host never opens it, whatever is behind it. With doors and a host who opens goat doors, switching wins with probability .
Play a few games by clicking a door, then press "Run 1,000 games". The chart shows the running win rate of stay (violet) and switch (aqua); the orange dashed lines are the exact values 1/3 and 2/3. Try 10 doors. Then choose "opens doors at random": the host may now show the car, and we keep only the games where he showed goats. Both strategies then win half of the kept games.
Now change the host. He does not know where the car is, and he opens one of the two other doors at random. He opens door 3, and it shows a goat. Call this observation . He chooses door 2 or door 3 with probability each, so:
- : he chooses door 3, and it has a goat;
- : he chooses door 3, and it has a goat;
- : door 3 has the car.
The two likelihoods are equal, so the posterior is for each closed door: switching does not help. The observation (a goat behind door 3) is the same as before, but it means something different, because the process that produced it is different.
In the Monty Hall game, the host does not know where the car is. He opens one of the two doors you did not pick, at random, and it shows a goat. What is the probability that switching wins?
The likelihood of "he opens door 3 and shows a goat" is if the car is behind your door 1, if it is behind door 2, and if it is behind door 3. With equal priors, the posterior of doors 1 and 2 is each. In the usual game, the likelihood given is (he must open door 3), and that asymmetry gives the .
3. Simpson's paradox. A real study compared two treatments for kidney stones (Charig et al., 1986). Treatment A was better for small stones (93.1% vs 86.7% success) and for large stones (73.0% vs 68.8%). But pooled over all patients, B looked better: 78.0% vs 82.6%.
| small stones | large stones | all patients | |
|---|---|---|---|
| A | 81 / 87 = 93.1% | 192 / 263 = 73.0% | 273 / 350 = 78.0% |
| B | 234 / 270 = 86.7% | 55 / 80 = 68.8% | 289 / 350 = 82.6% |
There is no error in the arithmetic. By the law of total probability, a pooled rate is a weighted average of the group rates: . A treated mostly large stones (263 of 350), which are harder; B treated mostly small ones (270 of 350). So the weights differ, and the ranking can flip.
Press "Pool the groups". Each block is one treatment. Its two columns are the patient groups, with widths proportional to the number of patients. The blue height is the success rate, so the blue area is the number of successes. Pooling levels the blue area inside each block without changing it; the yellow dashed line is the pooled rate. Then choose "same case mix": with equal weights, A wins pooled too.
Which answer is right, "A is better" or "B is better"? Probability alone cannot say; it depends on how the data were produced. Here stone size affects both the choice of treatment and the outcome, so the within-group comparison is the fair one. The causal inference track explains when to pool and when to split.
4. Selection bias: conditioning on a common effect. The collider example above is the general pattern. If you look only at cases selected by a common effect of two causes (patients in a hospital, accepted papers, hired people, alarms), you create a dependence between causes that are independent in the whole population. The causal graphs lesson shows it as a scatter plot (Berkson's paradox).
Answers to section 1. (1) About 10%: the exact value is . (2) Switch: switching wins with probability . (3) About 50%: the exact value is .
4. Worked example #
Setup. A bank's fraud detector checks card transactions. Let = "the transaction is fraud", with prior (1 in 1,000). The detector flags (event ) with (recall) and (false positive rate; the specificity is 0.98). A transaction is flagged. How likely is it to be fraud?
(a) With counts. Out of 100,000 transactions:
- are fraud, and are legitimate.
- The detector flags of the frauds.
- It flags of the legitimate transactions.
- So transactions are flagged, and
(b) With Bayes' rule. The evidence is . Then . The precision of the detector is under 5%, although its recall is 99%.
(c) A second detector. It has the same rates and is conditionally independent of the first given the true state (it uses different data). Use the odds form:
- prior odds ;
- likelihood ratio of one flag ;
- after one flag: odds , so (as in (a));
- after two flags: odds , so .
(d) Check the assumption. If both detectors read the same features, they are not conditionally independent: a false alarm of one makes a false alarm of the other likely. In the extreme case of two copies, the second flag has likelihood ratio 1, and the posterior stays at 0.047.
In the worked example (prior , each flag has likelihood ratio , detectors conditionally independent), how many flags in a row do you need before ?
Posterior probability means posterior odds . After flags the odds are . For : (). For : , so . On the log scale each flag adds , and you must climb from to .
5. In code #
NumPy checks the worked example: exact values first, then a simulation of 2 million transactions. Simulated numbers differ from the exact ones by the Monte Carlo error: about for the first estimate (about 42,000 flagged transactions) and about for the second (about 2,800 transactions flagged twice).
import numpy as np
from itertools import product
# (a) one detector: exact value with Bayes' rule
prior, recall, fpr = 0.001, 0.99, 0.02
evidence = recall * prior + fpr * (1 - prior) # law of total probability
print(round(evidence, 5), round(recall * prior / evidence, 4)) # 0.02097 0.0472
# (b) two conditionally independent detectors: odds form
odds = prior / (1 - prior) * (recall / fpr) ** 2
print(round(odds, 3), round(odds / (1 + odds), 3)) # 2.453 0.71
# (c) simulate many transactions and count
rng = np.random.default_rng(0)
n = 2_000_000
fraud = rng.random(n) < prior # true state H
p_flag = np.where(fraud, recall, fpr) # P(flag | state)
flag1 = rng.random(n) < p_flag # detector 1
flag2 = rng.random(n) < p_flag # detector 2: independent GIVEN the state
print(round(fraud[flag1].mean(), 3)) # 0.048 (exact 0.0472)
print(round(fraud[flag1 & flag2].mean(), 2)) # 0.72 (exact 0.710)
# without conditioning, the flags are NOT independent (common cause)
print(round((flag1 & flag2).mean(), 5), round(flag1.mean() * flag2.mean(), 5))
# 0.00137 0.00044 (exact 0.00138 and 0.00044)
# (d) XOR: pairwise independent, not mutually independent
outcomes = [(x, y, x ^ y) for x, y in product([0, 1], repeat=2)] # 4 equally likely outcomes
P = lambda event: sum(event(o) for o in outcomes) / 4
for i, j in [(0, 1), (0, 2), (1, 2)]:
print(P(lambda o: o[i] == 1 and o[j] == 1), P(lambda o: o[i] == 1) * P(lambda o: o[j] == 1))
# 0.25 0.25 (three times: every pair is independent)
print(P(lambda o: o == (1, 1, 1)), 0.5 ** 3) # 0.0 0.125
The last-but-one line of (c) shows the common-cause effect: the two flags are independent given the state, but not without conditioning, because both depend on whether the transaction is fraud.
6. Where it shows up #
- Precision depends on the base rate. Recall is ; precision is . Bayes' rule links them through the class prior. On rare classes (fraud, faults, rare diseases, extreme events), a classifier with high recall and a small false positive rate can still have low precision. This is one reason to report precision–recall curves, not only ROC curves, on very imbalanced data.
- Naive Bayes classifiers. A naive Bayes spam filter assumes that the words of an e-mail are conditionally independent given the class (spam or not spam). Then the posterior odds are the prior odds times one likelihood ratio per word, exactly the "multiply the likelihood ratios" rule. The assumption is false (words are correlated), so the probabilities are overconfident, but the ranking of e-mails is often good.
- Bayesian inference. is Bayes' rule for a parameter . With data that are independent given , the likelihood is a product over the data points (lessons 08 and 10). Thompson sampling for bandits samples from such a posterior.
- A/B tests and false discoveries. Suppose 10% of tested ideas really work, a test detects a real effect with probability 0.8 (its power), and a useless idea passes with probability 0.05. Then : 36% of the significant results are false discoveries (lessons 11–12, and the interview lesson on A/B testing).
- Graphical models. A Bayesian network, a hidden Markov model and the forward (noising) process of a diffusion model are all lists of conditional independences. They make a joint probability a product of small factors, by the chain rule.
- ML for science. Detecting rare events (earthquakes in continuous seismic records, extreme weather, faults in sensor networks) is a base-rate problem. Data assimilation is Bayes' rule: the forecast is the prior and the observation gives the likelihood (data assimilation lesson). Sensor fusion may multiply likelihoods only when the sensors are conditionally independent given the true state. Members of a weather ensemble share initial conditions and model physics, a common cause, so their errors are dependent (lesson 02 shows how this limits the gain from averaging).
7. Common mistakes #
- Swapping the conditioning. . This is the base-rate fallacy (in court: the prosecutor's fallacy). Always ask "out of how many?".
- Disjoint is not independent. Disjoint events with positive probabilities are strongly dependent: if one happens, the other cannot.
- Pairwise is not mutual. For three or more events, check every subset, also the triple (the XOR example).
- Multiplying likelihood ratios of dependent evidence. Two tests on the same sample, two sensors on the same cable, or two runs of the same model count the same evidence twice.
- Assuming independence survives conditioning. Conditioning on a common effect (an alarm, "the paper was accepted", "the patient is in hospital") creates dependence between independent causes. Conditioning on a common cause can remove a dependence.
- Ignoring how the information was produced. In Monty Hall, the same observed goat means different things for a host who knows and a host who opens at random. Write down the likelihood of what you observed, under each hypothesis.
- Adding probabilities of overlapping events. only for disjoint events; otherwise subtract , or use the union bound as an upper bound.
8. Check yourself #
- , , . Find . Are and
independent?
Answer
Inclusion–exclusion: . Yes, they are independent. - Prove: if and are independent, then and are independent.
Answer
is the disjoint union of and . So . - A family has two children, and at least one is a girl. What is the probability that both are
girls? What if you learn that the older child is a girl? (Assume boys and girls are equally
likely and independent.)
Answer
The four equally likely outcomes (older, younger) are GG, GB, BG, BB. "At least one girl" keeps GG, GB, BG, so . "The older is a girl" keeps GG, GB, so . The exact conditioning event matters. - You run 20 tests, each with false positive probability 0.05. Bound the probability of at least
one false positive. Which level per test guarantees at most 0.05?
Answer
The union bound gives , which says nothing. With level per test the bound is (the Bonferroni correction, lesson 11). For independent tests at level 0.05 the exact value is . - Two independent servers each fail with probability 0.1. An alarm rings if at least one fails.
Compute and .
Answer
, and , so . Given , the alarm is certain, so . and are independent, but dependent given the alarm (explaining away). - In the worked example, what is the second detector's likelihood ratio if both detectors always
agree (they are copies)?
Answer
Given the first flag, the second flag is certain under both hypotheses: . So its likelihood ratio is 1, and the posterior stays at 0.047.
Define the conditional probability .
for : keep only the outcomes in and rescale them to total 1.
State the law of total probability.
For a partition of with : .
State Bayes' rule and name its parts.
: posterior = likelihood × prior / evidence.
Write Bayes' rule in odds form.
: posterior odds = prior odds × likelihood ratio.
Prevalence 1%, sensitivity 90%, specificity 91%. Compute with 10,000 people.
100 sick give 90 true positives; 9,900 healthy give 891 false positives. .
What is the base-rate fallacy?
Reading (for example the sensitivity) as , and ignoring that a small prior makes most positives false.
Give three events that are pairwise but not mutually independent.
Two independent fair coins and : each pair is independent, but .
Why does conditioning on a common effect create dependence ("explaining away")?
Given the effect, one cause already explains it, so the other cause becomes less likely. Two independent server failures become dependent given "the alarm rang".
State the union bound.
, for any events, with no independence needed.
Why does switching win with probability 2/3 in the Monty Hall game?
The host must avoid the car, so his choice depends on where it is: but . Bayes' rule then gives .
9. Interview angle #
- "A test is 99% accurate (sensitivity and specificity). The prevalence is 1 in 10,000. You test positive. What is the probability that you are ill?" — About 1%: . Explain it with counts: of 1,000,000 people, 99 sick positives and about 10,000 healthy positives.
- "Your fraud model has 95% recall. Why can its precision still be low?" — With a tiny base rate, most flags are false: precision depends on the prior through Bayes' rule, not on recall alone.
- "Explain the Monty Hall problem." — Stay wins only if the first pick was right, probability 1/3. Otherwise the host is forced to leave the car closed, so switch wins with 2/3. If the host opens at random, the answer becomes 1/2.
- "Give three events that are pairwise but not mutually independent." — Two fair coins and their XOR.
- "Two sensors both report an anomaly. Can you multiply their likelihood ratios?" — Only if they are conditionally independent given the true state. Shared inputs, shared calibration or a shared cable break it, and multiplying counts the same evidence twice.
- "What is Simpson's paradox?" — A comparison that holds in every group reverses after pooling, because the groups have different weights (case mix) in the two arms. The kidney-stone data are the standard example.
10. Practice #
The notebook for this lesson runs in Colab or in your browser. It has five exercises, each with a check cell and a folded solution:
simulate_dice(n, rng): estimate for two dice by simulation, and compare with .posterior(prior, sens, spec)andposterior_two_tests(...): Bayes' rule for one and two conditionally independent tests, checked against counts from a simulation.monty_hall(n_games, switch, host, rng): simulate stay and switch, for a host who knows and a host who opens at random.- Build the XOR triple and write
is_independentto test pairwise and mutual independence. birthday(n): the exact probability of a shared birthday, a simulation, and the smallest with probability at least 0.5.
11. Watch and read #
- Joseph Blitzstein and Jessica Hwang, Introduction to Probability, 2nd edition, free PDF: ch. 1 (counting, birthday problem, the axioms) and ch. 2 (conditional probability, Bayes' rule, independence, Monty Hall and Simpson's paradox). The lecture videos of Statistics 110 follow the book; lecture 4 covers conditional probability.
- Allen Downey, Think Bayes 2, ch. 1 "Probability" and ch. 2 "Bayes's Theorem": Bayes tables in Python, including the Monty Hall problem.
- MIT 6.041, Probabilistic Systems Analysis and Applied Probability (OpenCourseWare): lectures 1–3 cover the axioms, conditioning, Bayes' rule and independence.
- Kevin Murphy, Probabilistic Machine Learning: An Introduction, free PDF: §2.2 (probability, conditional independence) and §2.3 (Bayes' rule, with a COVID-19 test example).
- C. R. Charig et al., Comparison of treatment of renal calculi by open surgery, percutaneous nephrolithotomy, and extracorporeal shockwave lithotripsy, BMJ 1986: the kidney-stone data of Simpson's paradox.
Runs in your browser with nothing to install. The notebook repeats the key demos and has exercises with checks; solutions are inside, folded.
No Google account needed: Python runs inside your browser. The first start downloads about 40 MB; your changes are saved in this browser only.