Probability tree & Bayes’ theorem
The classic setup: Bag I has 4 red and 4 black balls, Bag II has 2 red and 6 black balls. You pick a bag at random, then draw one ball. Forward is easy — given the bag, what's the chance of red? Backward is the real question: given the ball drawn is red, which bag did it probably come from? Move the sliders and watch total probability build P(A), then watch Bayes’ theorem run it in reverse.
Simulate N trials — watch probability become frequency
Pick bag at random, draw a ball, repeat N times with today's slider settings — then compare the observed frequencies to the theoretical values above.
The two theorems you're seeing
Total probability theorem
When E1 and E2 partition every possibility (mutually exclusive, cover everything), the overall chance of event A is just the sum of A happening via each path: P(A) = P(E1)P(A|E1) + P(E2)P(A|E2).
Bayes' theorem reverses the question
Instead of "given I picked Bag I, what's the chance of red?" (forward, easy), Bayes' theorem answers "given I drew red, what's the chance I picked Bag I?" (backward — harder, and usually the question you actually care about).
Why P(E1|A) ≠ P(A|E1)
These are genuinely different quantities — mixing them up is one of the most common probability errors. In the classic example P(A|E1) = 0.5 (half of Bag I is red), but P(E1|A) = 0.667 — given red was drawn, it's more likely from Bag I, because Bag I has the higher red proportion. Bayes' theorem is exactly the tool that converts one into the other.
The two Bayes' answers always add to 1
P(E1|A) + P(E2|A) = 1, always — because given that A definitely happened, it definitely came from either E1 or E2. There's no third option.
Part of the Probability chapter — read the notes, grab the formula sheet and take the quiz. One of Priodemy for School, free with every EduSuite school.
Bayes' theorem, and the trap it exposes
Reading a probability tree
A tree diagram turns a two-stage problem into something you can see. Each branch carries a conditional probability, and the rule is simple: multiply along a path to get the probability of that full sequence, then add across paths that lead to the same outcome. Adding the products of every route to a given result is the total probability theorem, and it is the denominator of every Bayes calculation.
The two questions that sound identical
Bayes' theorem exists because these two questions have very different answers:
- Given that a person has the disease, what is the probability the test is positive?
- Given that the test is positive, what is the probability the person has the disease?
The first is the test's accuracy, known from the manufacturer. The second is what a patient actually wants to know. Bayes' theorem converts one into the other by weighting with how common the condition is to begin with — the prior.
P(A|B) = P(B|A) · P(A) / P(B)
Why a 99% accurate test can still be usually wrong
This is the result worth internalising. Suppose a disease affects 1 person in 1000 and the test is 99% accurate in both directions. Test 100,000 people. Around 100 have the disease and about 99 of them test positive. But of the 99,900 healthy people, 1% — nearly 999 — also test positive.
So roughly 1,098 people receive a positive result, and only 99 of them are ill. The probability of actually having the disease given a positive test is about 9%, not 99%. Nothing is wrong with the test; the false positives drawn from the very large healthy group simply outnumber the true positives from the tiny sick group.
Set the prior low in the simulator and watch the posterior collapse, then raise it and watch it climb. This is why screening is targeted at higher-risk groups rather than whole populations, and why a positive screening result is normally followed by a second, different test.
Mistakes that cost marks
Confusing P(A|B) with P(B|A). These are different numbers, and swapping them — the "prosecutor's fallacy" — is the central error the topic is designed to catch. Write down explicitly which event is given before substituting.
Ignoring the prior. Rarity does most of the work in these problems. An answer that comes out close to the test's accuracy has almost certainly left the base rate out.
Forgetting that the partition must be exhaustive. The denominator sums over every route to the observed outcome. Missing one branch makes the total probability too small and every posterior too large — a useful check is that the posteriors across all causes must add to 1.
