Lesson 8 of 10, 13 min read

Tree diagrams, total probability and Bayes' theorem

Using tree diagrams for multi-stage experiments, the law of total probability, and Bayes' theorem with spam filters and medical tests.

Tree diagrams

For an experiment with stages, a tree diagram shows every path. Each branch carries the probability of that step given what happened before.

The law of total probability

\(20\%\) of a company's emails are spam. The word "free" appears in \(60\%\) of spam emails and in \(5\%\) of legitimate ones. What fraction of all emails contain "free"?

\[P(\text{free}) = 0.20 \cdot 0.60 + 0.80 \cdot 0.05 = 0.12 + 0.04 = 0.16\]

Bayes' theorem

Now reverse the question: an email contains "free". What's the probability it's spam?

\[P(\text{spam} \mid \text{free}) = \frac{0.12}{0.16} = 0.75\]

Seeing the word raised the probability of spam from \(20\%\) to \(75\%\). That's exactly how simple spam filters work: Bayes' theorem updates a probability in light of new evidence.

The medical test surprise

Practice

Quick check

In a tree diagram, how do you find the probability of one complete path?

Quick check

What does Bayes' theorem let you find?

Finished this lesson?

Mark it as completed and it's saved on this device. Sign up to see it everywhere.