Part I · Conditional Probability — Zooming In
Section 01

What “Given” Really Means

A probability is always a share of some crowd. The word “given” doesn't change the question — it changes the crowd. You stop looking at everyone and look only at the ones that match what you already know.

Here are 100 days of weather. Each tile is one day: grey = cloudy, yellow = sunny, and a blue drop means it rained. How likely is rain? It depends on what you already know about the sky.

Interactive — 100 Days of Weather CHOOSE WHAT YOU ALREADY KNOW · WATCH THE CROWD SHRINK
cloudy (40) sunny (60) rained (20)
20 / 100rainy days ÷ days in the crowd

The intuition to keep

Rain on a random day: 20%. Rain on a cloudy day: 45%. Same rain, different crowd. That is all conditional probability is — count inside the smaller crowd.

Section 02

The Universe Shrinks — From Counting to a Formula

Counting tiles becomes a formula once you swap counts for probabilities. Imagine the whole square has area 1. Then the area of a shape is its probability.

P(A | B) = P(A ∩ B)P(B) the part of A that lives inside B ÷ all of B — “B becomes the new whole”

Drag the two rectangles, resize them with their corner dot, then press Given B. The picture zooms until B fills the whole frame. What you see is literally the new universe — and the purple part's share of it is P(A | B).

Interactive — Zoom Into the Given Event DRAG TO MOVE · DRAG THE CORNER DOT TO RESIZE · AREA = PROBABILITY
UNIVERSE = THE WHOLE SQUARE (AREA 1)
A B A ∩ B

Notice two things while you play. First, when the rectangles don't overlap, P(A | B) = 0: once you know B happened, A is impossible (they are mutually exclusive). Second, P(A | B) and P(B | A) share the same top — the purple overlap — but divide by different wholes. That is the whole secret of the next section.

Section 03

Order Matters: P(A | B) ≠ P(B | A)

Same overlap, different crowd. Swapping what is “given” swaps the denominator — and the answer can change enormously.

Weather (Section 01)

P(rain | cloudy) = 18/40 = 0.45
P(cloudy | rain) = 18/20 = 0.90

Both share the 18 rainy-cloudy days. Different crowds: 40 cloudy days vs 20 rainy days.

Cricket

P(plays cricket | in Pakistan's team) ≈ 1
P(in Pakistan's team | plays cricket) ≈ 0

Same overlap (the 15 players). One crowd is 15 people, the other is millions.

Medicine

P(fever | flu) is high — most flu brings fever.
P(flu | fever) is much lower — many illnesses bring fever.

The connecting bridge

Both are built from the same joint probability:

P(A ∩ B) = P(A | B)·P(B) = P(B | A)·P(A)

Hold on to this line — Bayes' theorem is one division away from it.

Trap — confusing the inverse

Mixing up P(evidence | cause) with P(cause | evidence) is one of the most common reasoning errors — in exams, in courtrooms (the “prosecutor's fallacy”) and in medicine. Bayes' theorem is the tool that converts one into the other correctly.

Section 04

Independence — When “Given” Changes Nothing

Sometimes zooming in changes nothing: the share of A inside B is the same as the share of A everywhere. Then knowing B tells you nothing about A — the events are independent.

P(A | B) = P(A)  ⇔  P(A ∩ B) = P(A)·P(B) two coins, two dice, today's coin flip and tomorrow's — classic independent pairs

Below, each column is one group of students and the green part shows who passed. Column width is how big the group is. Move the sliders until the two green levels line up — that is what independence looks like.

Interactive — Does Studying Change the Odds? A = PASSED · B = STUDIED 5+ HOURS · WIDTH = SIZE OF GROUP
Look at the dashed line

The overall pass rate always sits between the two group rates — it is their average, weighted by group size. Remember that: it is the law of total probability, and it returns in Section 06.

Section 05

Probability Trees — The Multiplication Rule

Rearrange the conditional formula and you get the most useful rule in probability: to find the chance of “this and then that”, walk the path and multiply.

P(A ∩ B) = P(A) × P(B | A) first step × second step, where the second step already knows the first happened

A bag holds red and blue balls. Draw one, then draw another. Every branch of the tree carries a conditional probability — after a red ball leaves the bag, the bag has changed. Click any end of the tree to see its path multiplied out, and run a simulation to check the maths against reality.

Interactive — Two Draws From a Bag CLICK A LEAF · CHANGE THE BAG · TRY WITH / WITHOUT REPLACEMENT
Two quick checks a tree always passes

The branches leaving any node add up to 1. And the four leaf probabilities add up to 1 — every possible story is on the tree exactly once.

Section 06

The Law of Total Probability

What is the chance the second ball is red? It can happen along two different roads — red then red, or blue then red. Add up every road that ends where you want.

P(B) = P(B | A)·P(A) + P(B | A′)·P(A′) general form: P(B) = Σ P(B | Aᵢ)·P(Aᵢ) over every way Aᵢ the world could start
1
List the starting cases
first ball red (A) or blue (A′) — they cover everything and don't overlap
2
Walk each road to the evidence
P(R,R) = P(R)·P(R | R)   and   P(B,R) = P(B)·P(R | B)
3
Add the roads
P(2nd red) = P(R,R) + P(B,R)
4
Surprise check
with 3 red · 2 blue it equals 3/5 — the same as the first draw! (by symmetry)

In the tree above, press P(2nd red) to see both roads light up. In the student chart of Section 04 the same law drew the dashed line: overall pass rate = weighted average of the group pass rates. This sum is exactly the denominator of Bayes' theorem — which is where we go next.

Part II · Bayes' Theorem — Turning the Question Around
Section 07

Flip the Question — Bayes from the Tree

A tree answers forward questions easily: if the first ball is red, how likely is a red second? But often we see the end and want the start: the second ball was red — how likely was the first one red?

Bayes' theorem in one sentence: the road you care about ÷ all the roads that lead to what you saw. In symbols, start from the bridge of Section 03 and divide:

1
Same overlap, two ways
P(A | B)·P(B) = P(B | A)·P(A)
2
Divide both sides by P(B)
P(A | B) = P(B | A)·P(A) / P(B)
3
Expand the bottom (Section 06)
P(B) = P(B | A)·P(A) + P(B | A′)·P(A′)
4
Read it as roads
road of interest ÷ (road of interest + other roads)
P(A | B) = P(B | A) · P(A)P(B | A)·P(A) + P(B | A′)·P(A′) Bayes' theorem — green road ÷ (green road + amber road) in the tree below
Interactive — Run the Tree Backwards GREEN = ROAD OF INTEREST · AMBER = OTHER ROADS TO THE SAME EVIDENCE

Switch on with replacement and press the Bayes button again: the answer becomes exactly P(1st red). When draws are independent, seeing the second ball teaches you nothing about the first — Section 04 again.

Section 08

Prior, Likelihood, Evidence, Posterior

Each part of Bayes' theorem has a name, and the names tell the story of how we learn: start with a belief, see evidence, update the belief.

posterior = likelihood × priorevidence
Prior — P(A)

What you believed before the evidence. How common is the disease? How often is an email spam?

Likelihood — P(B | A)

How well the hypothesis explains the evidence. If you are sick, how often does the test say positive?

Evidence — P(B)

How common the evidence is overall, along every road (total probability). It rescales so everything adds to 1.

Posterior — P(A | B)

What you should believe after the evidence. Tomorrow, it becomes your new prior.

The intuition in one line

Strong evidence for a rare thing is still often a false alarm, because the rare thing has so few people to begin with. The prior matters as much as the evidence.

Section 09

The Medical Test — Think in People, Not Percentages

A disease affects 1% of people. A test catches 99% of sick people, and falsely flags 2% of healthy people. Your test is positive. Are you 99% likely to be sick?

Most people say yes. Let's test 1,000 people and simply count. Then press Only positive tests — that is the crowd you are actually in.

Interactive — Test 1,000 People P(SICK | POSITIVE) = TRUE ALARMS ÷ ALL ALARMS

sick · tested + sick · missed (−) healthy · false alarm (+) healthy · tested −

About 10 sick people test positive — but so do about 20 healthy people, because there are 99 times more healthy people to make mistakes on. A positive test means roughly 1 in 3, not 99%. Now raise the prevalence slider to 20% (say, a patient who already has symptoms): the same test suddenly becomes very convincing. The prior changes everything.

Section 10

Learning From Evidence — Update, Then Update Again

Bayes' theorem is not a one-off calculation; it is a learning loop. Today's posterior becomes tomorrow's prior. Take a second test and update again.

posterior odds = prior odds × likelihood ratio the fastest form of Bayes · odds = p / (1 − p) · likelihood ratio LR = P(evidence | sick) ÷ P(evidence | healthy)
Interactive — The Belief Meter EACH TEST RESULT UPDATES THE BELIEF · POSTERIOR → NEW PRIOR

Two positive tests in a row take the belief from 1% to about 96%: the second test starts from a much higher prior (33%). One negative result pulls it sharply back down. This loop — believe, observe, update — is how spam filters, medical diagnosis, self-driving cars and many machine-learning models reason under uncertainty.

Section 11

Practice — Your Turn

Answer as a decimal (0.62) or a percentage (62%). Draw a tree or picture a crowd of 1,000 first — it makes every problem easy.

Section 12

Traps & Formula Sheet

Trap 1 · Flipping the condition

P(positive | sick) is not P(sick | positive). Always ask: which crowd am I counting in?

Trap 2 · Ignoring the base rate

A great test for a rare condition still raises many false alarms. Never skip the prior.

Trap 3 · Assuming independence

Multiply P(A)·P(B) only when knowing one truly changes nothing about the other.

Habit · Count a crowd

Turn percentages into 1,000 people (natural frequencies). Bayes becomes simple counting.

Conditional
P(A | B) = P(A ∩ B) / P(B)
Multiplication rule
P(A ∩ B) = P(A) · P(B | A)
Independence
P(A | B) = P(A) ⇔ P(A ∩ B) = P(A)·P(B)
Total probability
P(B) = Σ P(B | Aᵢ) · P(Aᵢ)
Bayes' theorem
P(A | B) = P(B | A)·P(A) / P(B)
Bayes, expanded
P(B|A)P(A) / [P(B|A)P(A) + P(B|A′)P(A′)]
Odds form
post. odds = prior odds × P(B|A)/P(B|A′)
In words
road you want ÷ all roads to the evidence