Conditional probability
Use p(b|a), the chain rule p(a,b,c) = p(a)p(b|a)p(c|a,b), and Bayes' rule.
Builds on: Probability and distributions
What the animation says
Shrink the world
Here are a hundred emails. Twenty are spam, eighty are normal. Ten of the spam emails contain the word free. So do four of the normal ones. For the chance of free given spam, throw away everything except the twenty spam emails. Ten of those twenty contain free. Ten out of twenty is one half. Dividing by the kept group rescales it, so chances inside it add up to one. Now flip it. For spam given free, which group do we keep?
Same ten, different divisor
Keep only the fourteen free emails. Ten of them are spam: about point seven one. Same ten emails as before, divided by a different group. So the two answers differ. In general, the chance of b given a is the chance of both, divided by the chance of a. Turn it around: the chance of both equals the chance of a, times b given a. Check: spam is point two, free given spam is one half. Both together: point one, ten emails in a hundred.
One word at a time
That rearranged rule chains. Each new word multiplies in its chance, given all the words before it. A predictor says: the, point one. Cat given the, point zero two. Sat given the cat, point three. Multiply: point one times point zero two is point zero zero two. Times point three gives point zero zero zero six: the chance a text starts with the cat sat. Now add the word on, with chance one half given the cat sat. What's the new score?
Flip it with Bayes
Point zero zero zero three: every word multiplies, so scores shrink. A finished text also multiplies in an end marker. Now flip what is given. Spam's base rate is point two; not spam, point eight. Free appears in half of spam, but in only one in twenty normal emails. Two paths lead to free. Point two times one half is point one. Point eight times point zero five is point zero four. Together, free has chance point one four. Which number goes on top for spam given free?
Never swap them
Point one over point one four: about point seven one. That's exactly ten out of fourteen, from our email grid. Free given spam was one half. Spam given free is point seven one. Never assume they're equal. So: conditioning keeps one group and divides by its size. Multiplying in order gives a joint chance. Bayes swaps what is given.
Conditioning: shrink the world, then rescale
Three formulas, one idea
Scoring a sentence one word at a time
Bayes with numbers: spam given free
What to remember
On Bytewise this lesson comes in small steps with a check at the end, and the app brings it back right before you would forget it.
Bytewise
All courses