Math Playground
Data

Conditional probability

P(A given B) — once you know B happened, A's chances change.

The chance a random person has a rare disease is 0.1%. But given a positive test, it might still only be 2%. Conditioning on new information rewires probability — and almost everyone gets it wrong.

Conditional probability P(A | B) is the probability of A *given that* B has happened. Knowing B shrinks the sample space to just the B cases.

Where you'll meet this

Medical testing, spam filters, machine learning, legal evidence, weather — almost all real reasoning is conditional. Misreading it causes the 'prosecutor's fallacy' and bad medical decisions.

probabilityBayesML
Quick check

A test is 99% accurate. You test positive for a disease 1 in 1000 people have. Roughly what's the chance you actually have it?

Conditional probability

Restrict attention to the world where B happened; within that world, what fraction also has A?

Your turn

Roll a die. Given the result is even, what's P(it's a 2)?

Try it

Why P(A|B) ≠ P(B|A) in general — give a vivid case.

P(speaks English | is from the UK) ≈ 0.98. P(is from the UK | speaks English) ≈ 0.06. Swapping the condition gives wildly different answers — confusing them is the 'prosecutor's fallacy'.

Watch out

P(A | B) is not P(B | A). 'Most terrorists are men' doesn't mean 'most men are terrorists'. Always check which event you're conditioning on.

Run conditional probability backwards — from P(B|A) to P(A|B) — and you've discovered Bayes' theorem, the engine behind spam filters and modern statistics.

Recap
  • P(A | B) = P(A and B) / P(B) — restrict to the world where B happened.
  • P(A|B) ≠ P(B|A) — don't swap the condition.
  • Reversing the condition is exactly what Bayes' theorem does.