Visual Tools
Calculators
Tables
Mathematical Keyboard
Converters
Other Tools


Total Probability Visualizer


How to use: Select number of A events and B outcomes (inverse relationship). Adjust probabilities with sliders. Click on outcomes or marginal probabilities to highlight paths.
Every leaf is one branch probability times one conditional; all nine sum to 1. Learn more about the default tree · the law itself
P(A1) = 0.330P(A2) = 0.330P(A3) = 0.340P(B1|A1) = 0.400P(B2|A1) = 0.300P(B3|A1) = 0.300P(B1|A2) = 0.300P(B2|A2) = 0.500P(B3|A2) = 0.200P(B1|A3) = 0.200P(B2|A3) = 0.300P(B3|A3) = 0.500A10.3300A20.3300A30.3400A1 ∩ B10.1320A1 ∩ B20.0990A1 ∩ B30.0990A2 ∩ B10.0990A2 ∩ B20.1650A2 ∩ B30.0660A3 ∩ B10.0680A3 ∩ B20.1020A3 ∩ B30.1700

Probability Calculations

Marginal Probabilities P(Bⱼ)

P(B1) = P(A1)·P(B1|A1) + P(A2)·P(B1|A2) + P(A3)·P(B1|A3)
P(B1) = 0.2990
P(B2) = P(A1)·P(B2|A1) + P(A2)·P(B2|A2) + P(A3)·P(B2|A3)
P(B2) = 0.3660
P(B3) = P(A1)·P(B3|A1) + P(A2)·P(B3|A2) + P(A3)·P(B3|A3)
P(B3) = 0.3350

View All Paths Through A Event

Joint Probabilities P(Aᵢ ∩ Bⱼ)

A1 outcomes:
P(A1 ∩ B1) = 0.1320
P(A1 ∩ B2) = 0.0990
P(A1 ∩ B3) = 0.0990
A2 outcomes:
P(A2 ∩ B1) = 0.0990
P(A2 ∩ B2) = 0.1650
P(A2 ∩ B3) = 0.0660
A3 outcomes:
P(A3 ∩ B1) = 0.0680
P(A3 ∩ B2) = 0.1020
P(A3 ∩ B3) = 0.1700

Bayes' Theorem P(Aᵢ|Bⱼ)

Given B1:
P(A1|B1) = 0.4415
P(A2|B1) = 0.3311
P(A3|B1) = 0.2274
Given B2:
P(A1|B2) = 0.2705
P(A2|B2) = 0.4508
P(A3|B2) = 0.2787
Given B3:
P(A1|B3) = 0.2955
P(A2|B3) = 0.1970
P(A3|B3) = 0.5075







Using the Interactive Visualizer

The Total Probability Visualizer lets you explore how probabilities flow through partitioned sample spaces. Start by selecting the number of A events (2-5) and B outcomes (2-5) using the control buttons. Notice that these numbers have an inverse relationship - more A events means fewer possible B outcomes to keep the visualization readable.

The tree diagram shows probability paths from left to right. The first level branches represent your A events, each labeled with its probability P(Aᵢ). The second level shows all possible B outcomes for each A event, labeled with conditional probabilities P(Bⱼ|Aᵢ). Click on any outcome in the calculations panel to highlight its corresponding path through the tree.

Use the "Customize Data" button to reveal probability sliders. Adjust P(A) values and they automatically normalize to sum to 1. Similarly, conditional probabilities P(B|A) for each A event normalize across their row. Watch how the tree diagram and calculations update in real-time as you modify probabilities.

Understanding the Calculations Panel

The right panel displays four types of probability calculations. The Marginal Probabilities section shows P(Bⱼ) for each outcome, calculated using the total probability formula by summing across all paths that lead to that outcome. Click any marginal probability to highlight all contributing paths in the tree.

The View All Paths buttons let you highlight every path passing through a specific A event, making it easy to see how that partition element contributes to different outcomes. The Joint Probabilities section displays P(Aᵢ ∩ Bⱼ) for every combination, calculated by multiplying along each path from start to endpoint.

The Bayes' Theorem section shows reversed conditional probabilities P(Aᵢ|Bⱼ), demonstrating how to work backward from observed outcomes to determine which partition element likely occurred. These calculations automatically update as you adjust your probability values, providing instant feedback on how changes propagate through the system.

The Default Tree

The visualizer opens on a three-part partition. From the start node, three branches carry P(A1)=0.33P(A_1) = 0.33, P(A2)=0.33P(A_2) = 0.33 and P(A3)=0.34P(A_3) = 0.34; each then splits into three outcomes carrying the conditional probabilities P(BjmidAi)P(B_j mid A_i).

Multiplying along any root-to-leaf path gives that path's joint probability. The first path, for instance, is 0.33imes0.4=0.1320.33 imes 0.4 = 0.132, which is P(A1capB1)P(A_1 cap B_1).
P(A1) = 0.330P(A2) = 0.330P(A3) = 0.340P(B1|A1) = 0.400P(B2|A1) = 0.300P(B3|A1) = 0.300P(B1|A2) = 0.300P(B2|A2) = 0.500P(B3|A2) = 0.200P(B1|A3) = 0.200P(B2|A3) = 0.300P(B3|A3) = 0.500A1P = 0.330A1 ∩ B1 = 0.132A1 ∩ B2 = 0.099A1 ∩ B3 = 0.099A2P = 0.330A2 ∩ B1 = 0.099A2 ∩ B2 = 0.165A2 ∩ B3 = 0.066A3P = 0.340A3 ∩ B1 = 0.068A3 ∩ B2 = 0.102A3 ∩ B3 = 0.170
Default tree, nothing highlighted

Three branches into three outcomes: 12 edges, 13 nodes. Every root-to-leaf product is a joint probability, and the nine of them sum to 1.

Two conditions make the tree a valid partition, and both are visible in the numbers. The branch probabilities sum to 1, so the AiA_i cover the whole sample space; and each fan of conditionals sums to 1, so within any branch the outcomes are exhaustive.

Nine leaves, nine joint probabilities, and they sum to 1 as well. Every point of the sample space lands on exactly one leaf — that is what "partition" buys, and it is the reason the law of total probability can add path probabilities without any risk of double counting.

Following a Single Branch

Clicking a partition event highlights everything downstream of it. In the frozen picture below, A1A_1 is selected: its branch and all three of its outcomes are drawn in colour while the rest of the tree fades to grey.

What is highlighted is the conditional world "given A1A_1". Inside it the three conditional probabilities 0.40.4, 0.30.3, 0.30.3 sum to 1 — they are a complete probability distribution in their own right.
P(A1) = 0.330P(A2) = 0.330P(A3) = 0.340P(B1|A1) = 0.400P(B2|A1) = 0.300P(B3|A1) = 0.300P(B1|A2) = 0.300P(B2|A2) = 0.500P(B3|A2) = 0.200P(B1|A3) = 0.200P(B2|A3) = 0.300P(B3|A3) = 0.500A1P = 0.330A1 ∩ B1 = 0.132A1 ∩ B2 = 0.099A1 ∩ B3 = 0.099A2P = 0.330A2 ∩ B1 = 0.099A2 ∩ B2 = 0.165A2 ∩ B3 = 0.066A3P = 0.340A3 ∩ B1 = 0.068A3 ∩ B2 = 0.102A3 ∩ B3 = 0.170
Branch A1 highlighted

One partition event selected, so its branch and its three outcomes stay coloured while the rest fades. Inside that sub-tree the conditionals 0.4, 0.3, 0.3 sum to 1 on their own.

This view separates two quantities the notation makes easy to confuse. P(B1midA1)=0.4P(B_1 mid A_1) = 0.4 is the probability *within* the highlighted sub-tree, and it is the number on the edge. P(A1capB1)=0.132P(A_1 cap B_1) = 0.132 is the probability of that leaf *within the whole tree*, and it is the number at the node — the edge value scaled down by the 0.330.33 it took to reach the branch at all.

Conditioning is exactly that rescaling. Restricting attention to A1A_1 makes its probability the new total, and dividing through by 0.330.33 is what turns joint probabilities back into conditional ones.

Summing Across Branches: the Law Itself

Clicking an outcome instead highlights one BjB_j across every branch. The still shows B2B_2 selected, so the three paths ending in B2B_2 are lit and the others fade.

Those three paths are exactly the terms of the law of total probability:

P(B2)=0.33imes0.3+0.33imes0.5+0.34imes0.3=0.366P(B_2) = 0.33 imes 0.3 + 0.33 imes 0.5 + 0.34 imes 0.3 = 0.366
P(A1) = 0.330P(A2) = 0.330P(A3) = 0.340P(B1|A1) = 0.400P(B2|A1) = 0.300P(B3|A1) = 0.300P(B1|A2) = 0.300P(B2|A2) = 0.500P(B3|A2) = 0.200P(B1|A3) = 0.200P(B2|A3) = 0.300P(B3|A3) = 0.500A1P = 0.330A1 ∩ B1 = 0.132A1 ∩ B2 = 0.099A1 ∩ B3 = 0.099A2P = 0.330A2 ∩ B1 = 0.099A2 ∩ B2 = 0.165A2 ∩ B3 = 0.066A3P = 0.340A3 ∩ B1 = 0.068A3 ∩ B2 = 0.102A3 ∩ B3 = 0.170
Outcome B2 highlighted across every branch

The three paths ending in B2 are lit. Their joint probabilities - 0.099, 0.165, 0.102 - are the terms of the law of total probability, summing to P(B2) = 0.366.

This is the picture the whole tool is built around. An event that is awkward to compute directly is decomposed into the ways it can happen — one per partition branch — and those pieces are added.

The reason the addition is legitimate is that the branches are disjoint. B2B_2 can occur with A1A_1, with A2A_2 or with A3A_3, never with two at once, so the three joint probabilities can be summed without correction. That disjointness is why the partition condition matters and why this is not the general addition rule, which needs an intersection term subtracted.

Highlighting each outcome in turn gives 0.2990.299, 0.3660.366 and 0.3350.335 — the three BB marginals, summing to 1.

Changing the Partition Size

Nothing in the law fixes the number of branches. The controls let the partition run from two to five parts, with the outcome count adjusting inversely.

The frozen picture is a four-part partition, each branch carrying 0.250.25. The tree is wider, there are twelve leaves instead of nine, and the marginals still sum to 1.
P(A1) = 0.250P(A2) = 0.250P(A3) = 0.250P(A4) = 0.250P(B1|A1) = 0.400P(B2|A1) = 0.300P(B3|A1) = 0.300P(B1|A2) = 0.300P(B2|A2) = 0.500P(B3|A2) = 0.200P(B1|A3) = 0.200P(B2|A3) = 0.300P(B3|A3) = 0.500P(B1|A4) = 0.500P(B2|A4) = 0.250P(B3|A4) = 0.250A1P = 0.250A1 ∩ B1 = 0.100A1 ∩ B2 = 0.075A1 ∩ B3 = 0.075A2P = 0.250A2 ∩ B1 = 0.075A2 ∩ B2 = 0.125A2 ∩ B3 = 0.050A3P = 0.250A3 ∩ B1 = 0.050A3 ∩ B2 = 0.075A3 ∩ B3 = 0.125A4P = 0.250A4 ∩ B1 = 0.125A4 ∩ B2 = 0.063A4 ∩ B3 = 0.063
A four-part partition

The same construction with four branches of 0.25 each and twelve leaves. The marginals still sum to 1; only the number of terms changed.

The statement generalises without change: P(B)=sumiP(Ai)P(BmidAi)P(B) = sum_{i} P(A_i) P(B mid A_i), over however many branches the partition has. Two is enough — the common case is a partition into an event and its complement, P(B)=P(A)P(BmidA)+P(Ac)P(BmidAc)P(B) = P(A)P(B mid A) + P(A^c)P(B mid A^c) — and the sum extends to any finite number.

What does change is the arithmetic burden. Each extra branch adds a term to every marginal, which is why the tree view stops being practical well before the mathematics does. The principle is what transfers; the drawing is a teaching aid that runs out of room first.

What is the Law of Total Probability?

The law of total probability provides a method for calculating the probability of an event B by considering all possible ways B can occur through a partition of the sample space. If events A₁, A₂, ..., Aₙ form a partition (mutually exclusive and exhaustive), then the probability of any event B is given by:

P(B)=i=1nP(Ai)P(BAi)P(B) = \sum_{i=1}^{n} P(A_i) \cdot P(B|A_i)


This formula says that to find P(B), we sum the probabilities of B occurring through each partition element Aᵢ. Each term P(Aᵢ) · P(B|Aᵢ) represents one path to B through the partition. The visualizer displays this graphically - each path from start to a B outcome corresponds to one term in this sum.

The power of this theorem lies in breaking complex probability problems into simpler conditional pieces. When direct calculation of P(B) is difficult, partitioning the sample space into cases where conditional probabilities are easier to determine makes the problem tractable.

Partitions of the Sample Space

A partition of the sample space is a collection of events that are mutually exclusive (no overlap) and collectively exhaustive (cover all possibilities). In the visualizer, the A events form a partition - exactly one A event occurs in any outcome, and together they account for all possibilities.

Mathematically, events A₁, A₂, ..., Aₙ partition the sample space if: (1) Aᵢ ∩ Aⱼ = ∅ for all i ≠ j (mutually exclusive), and (2) A₁ ∪ A₂ ∪ ... ∪ Aₙ = S (collectively exhaustive). These properties ensure that probabilities P(A₁), P(A₂), ..., P(Aₙ) sum to exactly 1.

Common partitions include: categorizing by different scenarios (rainy/sunny, male/female, treatment groups in experiments), age groups in demographic studies, or different disease states in medical testing. The visualizer lets you explore how outcomes distribute across partition elements and how this affects total probabilities.

Connection to Bayes' Theorem

The law of total probability and Bayes' theorem are intrinsically connected. While total probability calculates P(B) by conditioning on partition elements, Bayes' theorem reverses this to find P(Aᵢ|B):

P(AiB)=P(Ai)P(BAi)P(B)=P(Ai)P(BAi)j=1nP(Aj)P(BAj)P(A_i|B) = \frac{P(A_i) \cdot P(B|A_i)}{P(B)} = \frac{P(A_i) \cdot P(B|A_i)}{\sum_{j=1}^{n} P(A_j) \cdot P(B|A_j)}


Notice that the denominator is exactly the total probability formula. This connection means the two theorems work together - total probability computes the normalizing constant needed for Bayes' theorem. The visualizer displays both: marginal P(B) values use total probability, while the Bayes' theorem section shows the reversed conditionals.

This relationship is crucial in statistical inference. Given an observed outcome B, Bayes' theorem determines which partition element Aᵢ most likely caused it, using the total probability of B as the normalizing factor. The visualizer lets you see how prior probabilities P(Aᵢ) and likelihoods P(B|Aᵢ) combine to produce posterior probabilities P(Aᵢ|B).

Joint and Marginal Probabilities

Joint probabilities P(Aᵢ ∩ Bⱼ) represent the probability that both events occur simultaneously. In the tree diagram, each endpoint corresponds to a joint probability, calculated by multiplying along the path: P(Aᵢ ∩ Bⱼ) = P(Aᵢ) · P(Bⱼ|Aᵢ). Click any joint probability in the panel to see its path highlighted.

Marginal probabilities are obtained by summing joint probabilities. The marginal P(Bⱼ) is found by summing all joint probabilities involving Bⱼ across different A events: P(Bⱼ) = Σᵢ P(Aᵢ ∩ Bⱼ). This is exactly the total probability formula - marginal probabilities are computed using total probability.

The relationship between joint and marginal probabilities is fundamental to probability theory. Marginals represent "overall" probabilities ignoring certain variables, while joints represent "specific" probabilities of combinations. The visualizer shows both simultaneously, helping you understand how conditioning on partition elements (the A events) breaks down marginal probabilities into their joint components.

Real-World Applications

The law of total probability appears throughout practical probability problems. In medical diagnosis, doctors partition patients by test results (positive/negative) and use total probability to find overall disease prevalence: P(Disease) = P(Test+)·P(Disease|Test+) + P(Test-)·P(Disease|Test-).

In quality control, manufacturers partition production by machine or shift. The probability of a defective item is: P(Defective) = Σ P(Machineᵢ)·P(Defective|Machineᵢ). This helps identify which machines or shifts contribute most to defects.

Risk assessment in finance and insurance uses partitions by economic scenarios. The total probability of a loss event considers all possible economic conditions: P(Loss) = Σ P(Scenarioᵢ)·P(Loss|Scenarioᵢ). The visualizer's interactive nature makes it easy to explore how different scenario probabilities affect overall risk.

Probability Trees and Path Analysis

Probability trees provide a visual representation of sequential or conditional probability structures. Each branch represents a possible outcome with its associated probability. In the total probability context, the first level branches show the partition (A events), and second level branches show outcomes (B events) conditional on each partition element.

Path probabilities are calculated by multiplying probabilities along the path. A path from start through Aᵢ to Bⱼ has probability P(Aᵢ) · P(Bⱼ|Aᵢ) = P(Aᵢ ∩ Bⱼ). The tree structure makes this multiplication rule visual and intuitive. The visualizer highlights paths when you click outcomes, showing exactly which probabilities multiply together.

Trees excel at organizing complex conditional relationships. When multiple stages of conditioning exist, trees prevent confusion about which probabilities to multiply versus add. The total probability theorem corresponds to summing across all paths reaching the same endpoint - the visualizer makes this summation explicit in the marginal probability calculations.

Common Mistakes and Misconceptions

A common error is confusing P(B|A) with P(A|B). The total probability formula uses P(B|A) values (likelihoods of B given different A events), not the reverse. The visualizer's tree structure helps prevent this - arrows point from A to B, showing the direction of conditioning clearly.

Another mistake is forgetting that partition elements must be exhaustive. If your A events don't cover all possibilities, the total probability formula gives an incomplete answer. The visualizer enforces this - probabilities P(Aᵢ) always sum to 1, ensuring the partition is complete.

Some students incorrectly try to apply total probability without a proper partition. The theorem requires mutually exclusive, exhaustive events. Using overlapping categories or incomplete sets leads to wrong answers. The visualizer's structure - where you must specify distinct A events that account for all probability mass - reinforces the partition requirement.

Total Probability vs. Addition Rule

The total probability theorem is sometimes confused with the basic addition rule for mutually exclusive events. While both involve summing probabilities, they apply in different contexts. The addition rule P(A ∪ B) = P(A) + P(B) combines probabilities of mutually exclusive events A and B directly.

Total probability, by contrast, calculates P(B) by conditioning on a partition: P(B) = Σ P(Aᵢ)·P(B|Aᵢ). This is necessary when you don't know P(B) directly but do know how likely B is under different partition elements. The multiplication by P(Aᵢ) weights each conditional probability by how likely that partition element is.

Think of it this way: addition rule combines alternatives (A or B), while total probability combines pathways (B through A₁, or B through A₂, etc.). The visualizer shows these pathways explicitly - each path to a B outcome represents one term in the total probability sum.

Practice Problems and Exercises

Use the visualizer to explore these scenarios:

Problem 1 - Medical Testing: Set up two A events (Disease, No Disease) with P(Disease) = 0.01. Set conditional probabilities P(Test+|Disease) = 0.95 and P(Test+|No Disease) = 0.05. Use total probability to find P(Test+). The visualizer shows this equals 0.01·0.95 + 0.99·0.05 = 0.059.

Problem 2 - Manufacturing: Create three A events for three machines with P(M₁) = 0.5, P(M₂) = 0.3, P(M₃) = 0.2. Set defect rates P(Defect|M₁) = 0.02, P(Defect|M₂) = 0.05, P(Defect|M₃) = 0.03. Calculate overall defect probability using total probability.

Problem 3 - Weather: Set A events for weather conditions (Sunny, Cloudy, Rainy). Choose reasonable probabilities for each. Then set conditional probabilities for traffic delay given each weather condition. Use total probability to find overall delay probability. Experiment with different weather probabilities to see how total delay probability changes.