Probability Tree & Bayes
Build a probability tree, drop Monte Carlo balls through it and condition on evidence to see Bayes' theorem at work.
P(Sick | Positive) = P(Positive | Sick) × P(Sick) ÷ P(Positive) = 90% × 1% ÷ 9.8% = 9.2%
Out of 1,000 cases, about 98 match Positive, and 9 of them are Sick: 9 in 98.
Balls fall down the tree, taking each branch with its chance, and pile up at the leaves. In the Tree and Flipped tree views, tap a leaf or a node to condition on that evidence: balls that don't match fade, and the share that remain shows Bayes' rule at work. Tap Start to drop 100 at once, an event in time that Restart and share links leave out. Taps do nothing in the 1,000 cases view.
How is Probability Tree & Bayes working for you?
About Probability Tree & Bayes
- Bayes' rule
- P(A | E) = P(E | A) × P(A) ÷ P(E)
- First published
- 1763, by Richard Price from Thomas Bayes's papers
- Medical test preset
- A positive test means about a 9% chance of being sick
- Monty Hall preset
- Switching wins 2 games in 3
A probability tree lays a chance process out as branches. The first level is the cause, such as whether a person is sick, and each level after it is a piece of evidence, such as a test result, whose branch chances depend on everything above it. Multiplying the chances along a path gives the chance of that whole path. This tool lets you build a tree with up to three levels, edit every branch, and watch balls fall through it: each ball takes every branch with its chance, so the piles at the leaves grow toward the exact path probabilities shown beside them, a Monte Carlo simulation in the sense Nicholas Metropolis and Stanislaw Ulam described in 1949.
Conditioning on evidence keeps only the balls that match it. Tap a leaf or pick an outcome under Evidence, and the non-matching balls fade; the share of the remaining balls that have the cause is the posterior probability, and the panel works it out with Bayes' rule, P(A | E) = P(E | A) × P(A) ÷ P(E), from the essay of Thomas Bayes that Richard Price published in 1763. The Medical test shows why the rule matters: when 1 person in 100 is sick and the test catches 90% of cases but also flags 9% of healthy people, a positive result means only about a 9% chance of being sick, because the healthy majority produces most of the positives. Flip the tree to see the same chances with the evidence first, where the posterior sits on a branch.
Counts are easier to reason with than percentages, as Gerd Gigerenzer and Ulrich Hoffrage showed in 1995, so the 1,000 cases view draws the expected people (or cabs, games or emails) as icons: about 98 positives, of whom 9 are sick. Try the Taxi cab problem from Amos Tversky and Daniel Kahneman, the Monty Hall problem that Steve Selvin posed in 1975, two tests in a row, or a spam filter, then download the leaf counts as CSV or record the simulation.
How to use Probability Tree & Bayes
- Pick a problem. Choose Medical test, Second test, Taxi cab, Monty Hall or Spam filter, or build a tree: its levels, outcomes and names under Setup, and its chances under Model.
- Watch the balls. Balls drop from Start and take each branch with its chance. The bins show how many landed at each leaf against the exact chance; tap Start or press Drop 1,000 for more.
- Condition on evidence. In the Tree and Flipped tree views, tap a leaf or a node, or choose an outcome under Evidence. Balls that don't match fade, and the readout works out Bayes' rule with the numbers filled in.
- Ask about any cause. Use Chance of, or tap a first-level node, to choose which cause the posterior is about, such as Door 2 in Monty Hall.
- Change the chances. Drag the sliders under Model; each is the chance of an outcome given the outcomes before it, and its sibling adjusts so the branches still add up to 100%.
- Change the views. Flipped tree puts the evidence first so the posterior appears as a branch, and 1,000 cases shows the same chances as counts of people.
- Export. Save a PNG, a video or GIF, or the leaf counts with their exact chances as a CSV file. Record 30 s from the start drops the balls again from the beginning and records the first 30 seconds.
Frequently asked questions
What is a probability tree?
A diagram of a chance process in stages. Each branch is labeled with the chance of its outcome given the branches before it, the chances leaving any node add up to 1, and the chance of a whole path is the product of the chances along it. Adding up the paths that match an event gives the event's chance.
What is Bayes' theorem?
It turns a conditional chance around: P(A | E) = P(E | A) × P(A) ÷ P(E). Here P(A) is the prior chance of the cause, P(E | A) is how likely the evidence is if the cause is true, and P(E) is the overall chance of the evidence. In the tree, P(E) is the total of all paths that end in E, and the posterior P(A | E) is the share of those paths that start with A.
Why does a positive test so often mean you aren't sick?
Because the condition is rare. In the Medical test, 1% of people are sick: of 1,000 people, about 10 are sick and 9 of them test positive, but 9% of the 990 healthy people, about 89, also test positive. So only 9 of the roughly 98 positives are sick, about 9%. Ignoring the low starting chance is called base-rate neglect, and a second positive test raises the chance to about 50%.
How does the Monty Hall problem work?
You pick door 1, and the host, who knows where the car is, opens another door with a goat behind it, here door 3. If the car is behind door 1, the host could open either door; if it is behind door 2, he must open door 3. Opening door 3 is twice as likely when the car is behind door 2, so switching wins 2 games in 3, as the Monty Hall preset shows.
What is the taxi cab problem?
In Tversky and Kahneman's version, 85% of a city's cabs are green and 15% are blue. A witness says the cab in an accident was blue and is right 80% of the time in tests. Most people say the cab was probably blue, but the chance is only about 41%, because there are so many more green cabs that the witness's mistakes about them outnumber the correct reports of blue ones.
What does the Monte Carlo simulation add?
It shows where the formula comes from. Every ball is one random case, and the share of matching balls that have the cause is the posterior estimated by counting. As more balls fall, the estimate settles on the exact value drawn as a dashed line, by the law of large numbers.
References
- Bayes, T., & Price, R. (1763). An essay towards solving a problem in the doctrine of chances. Philosophical Transactions of the Royal Society of London 53, 370–418.
- Gigerenzer, G., & Hoffrage, U. (1995). How to improve Bayesian reasoning without instruction: Frequency formats. Psychological Review 102(4), 684–704.
- Tversky, A., & Kahneman, D. (1982). Evidential impact of base rates. In D. Kahneman, P. Slovic & A. Tversky (Eds.), Judgment under Uncertainty: Heuristics and Biases, 153–160. Cambridge University Press.
- Selvin, S. (1975). A problem in probability (letter to the editor). The American Statistician 29(1), 67.
- Metropolis, N., & Ulam, S. (1949). The Monte Carlo method. Journal of the American Statistical Association 44(247), 335–341.





