Probability tree

Set P(A), P(B | A) and P(B | A′) with sliders and see the tree, the four path probabilities, P(B) by total probability, P(A | B) by Bayes' theorem and an independence check. 1000 dots show the same numbers as people, which makes it clear why a positive result on a test for something rare is often a false alarm.

Keep it one tap away for everyday use.

Bookmark Probability tree?

Press Ctrl + D now. Your browser opens its own bookmark box, where you choose the name and folder.

  1. Set chances
  2. Tree
  3. Bayes
  4. 1000 dots
Nothing is uploadedWorks offline once open

Set up the tree

The tree

Multiply along a path to get the chance of both. Add the paths that end in B to get P(B). Highlighted: the paths that end in B.

The same, with 1000 dots

Try this

  • In the screening test, only 9 of the 59 people who test positive have the condition: P(A | B) is about 15 %, even though the test catches 90 %. The condition is rare, so false alarms outnumber true ones.
  • Raise P(A) from 1 % to 20 % and watch P(A | B) jump. The base rate matters.
  • Set P(B | A) equal to P(B | A′): A and B become independent, and P(A | B) = P(A).
  • Pick the coin tosses: the second toss does not care about the first.

Check yourself

Fresh numbers every time. Type a number or a fraction such as 3/4; nothing is saved or sent.

    What it shows

    Many probability questions happen in two stages: first something happens or not (event A), then something else happens or not (event B), and the chance of B depends on what happened first. A tree diagram shows this: two branches for A and A′, then two branches for B and B′ from each. You multiply along a path to get the chance of that path, and add paths to get the chance of an outcome.

    This page draws the tree from three numbers, P(A), P(B | A) and P(B | A′), and works out:

    • the four path probabilities P(A ∩ B), P(A ∩ B′), P(A′ ∩ B) and P(A′ ∩ B′);
    • P(B) by the theorem of total probability;
    • P(A | B), the chance of A once you know B happened, by Bayes’ theorem;
    • whether A and B are independent.

    Underneath, 1000 dots show the same tree as people (or days, or marbles), which makes Bayes’ theorem a matter of counting.

    It follows probability in Class 12 maths (conditional probability, the multiplication rule, total probability, Bayes’ theorem and independent events). Sets and their regions come first in the venn diagram calculator calculator; afterwards, the probability distribution explorer covers binomial and other distributions, and the diagnostic test calculator applies the same idea to real test statistics.

    How to use it

    1. Pick a story (two bags of marbles, rain and a late bus, a screening test, two coin tosses) or choose My own names and name the events.
    2. Slide P(A), P(B | A) and P(B | A′). The tree, the facts and the dots update as you slide.
    3. Read P(A | B) in the facts and the sentence under them.
    4. In the dots, the filled dots are the cases where B happened. Count how many of those are blue (A as well): that fraction is P(A | B).

    Worked example (a teaching model)

    Suppose 1 % of people have a condition (P(A) = 0.01), a test catches 90 % of them (P(B | A) = 0.9) and wrongly flags 5 % of the rest (P(B | A′) = 0.05). Then P(A ∩ B) = 0.01 × 0.9 = 0.009 and P(A′ ∩ B) = 0.99 × 0.05 = 0.0495, so P(B) = 0.0585. Bayes gives P(A | B) = 0.009 / 0.0585 ≈ 0.1538: only about 15 % of positive results are true. In dots: of 1000 people, 9 true positives and 50 false alarms, and 9 ÷ 59 ≈ 15 %. The numbers are made up for teaching and are not medical advice.

    Independence

    A and B are independent when knowing A does not change the chance of B, that is P(B | A) = P(B | A′). Then P(A ∩ B) = P(A) × P(B) and P(A | B) = P(A). The coin-toss story shows this.

    Check yourself

    Five questions with fresh numbers: a path probability, P(B), P(A | B), a two-bags problem and independent events. Nothing is saved.

    FAQ

    Why is P(A | B) so different from P(B | A)? P(B | A) looks only at the A branch; P(A | B) compares the A ∩ B path with every path that ends in B, including the big A′ ∩ B path when A is rare.

    Is this from my textbook? It covers the standard school topic with its own examples. It is an independent study aid.

    Where the numbers come from

    • Standard probability: the multiplication rule, the theorem of total probability, Bayes' theorem and independence. Written for fibub; no textbook text, figures or exercises are used. All story numbers are made up, and the screening example is a teaching model, not medical advice.
    • Checked against exact fractions computed with Python's fractions module for four trees.

    Standard scientific values, such as constants, atomic weights and melting points, are facts found in every textbook; we name where ours were checked. If you are an author or publisher and want a value, a credit or a table changed or removed, tell us and we will act quickly.

    Read more on the Blog

    Last updated 2026-11-09.

    Change log for Probability tree

    1. Add #1191 Probability tree and Bayes Details on GitHub

    Every change to fibub

    Related tools

    Diagnostic test calculator #T312 Sensitivity, specificity, predictive values, likelihood ratios and accuracy from a 2 × 2 table, with exact or Wilson 95 % intervals. Turn a pre-test probability into a post-test probability and see it on a Fagan nomogram. Probability distribution explorer #T391 Pick a distribution (normal, t, chi-squared, F, beta, gamma, Weibull, binomial, Poisson and 26 more), set its parameters and see the curve with the probability between two values shaded, the quantiles, mean, variance, skewness and kurtosis, and draw seeded random samples. Matches scipy.stats. Venn diagram calculator #L89 Type any set expression with union, intersection, complement and difference for 2 or 3 sets and see the region shaded on a Venn diagram. Compare two expressions to check De Morgan's laws, put in real lists of elements, and count with n(A ∪ B) = n(A) + n(B) − n(A ∩ B). Binomial expansion #L95 Expand (ax + b)ⁿ with exact coefficients, read them off Pascal's triangle, find the general term T(r+1) and the middle term(s), and drop balls through a Galton board to watch the same numbers turn into chances. Infection spread #L100 A town of 400 dots: ill people meet others and pass a made-up illness on. Change how many people they meet, the chance of passing it on, days ill and the share vaccinated, and watch R0 and herd immunity at work. A study tool only. Probability spinner designer #L163 Design a spinner with up to six coloured sectors, read each probability as angle ÷ 360°, then spin once or a thousand times and watch the share of landings settle near the theory. At Class 12 level give each sector points and find the expected score. Histogram builder #L167 Type a list of numbers and drag the class width and starting point to watch the frequency table, the histogram and the frequency polygon change. See the mean, median, mode and modal class, how far the mean from the table drifts from the true mean, and the combined mean of two groups. Counting machine #L234 Seat people in a row, pick a team or shuffle the letters of a word and see every arrangement listed for small cases. nPr and nCr are worked side by side with your numbers, and repeated letters (BANANA, MISSISSIPPI) are handled with n!/(p! q!). Event algebra #L240 Roll two dice (or a coin and a die) and see all the outcomes as a grid. Choose events A and B, shade them, outline A ∪ B, A ∩ B, A′, A − B or B − A, and watch the addition rule P(A ∪ B) = P(A) + P(B) − P(A ∩ B) worked out with the counts. Mutually exclusive and exhaustive events are flagged, and a simulation checks the answer. Random variable builder #L311 Build a probability distribution table (or pick coins, dice, drawing without replacement or a binomial with sliders) and get the mean, E(X²), variance and standard deviation with every step, a bar chart with μ and μ ± σ, and a simulation that runs the experiment 10 to 10 000 times so you can watch the average settle on the mean.