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.
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.

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.

Related Probability Concepts

Conditional Probability forms the foundation of total probability. Understanding P(B|A) is essential before applying the total probability theorem. For detailed coverage of conditional probability, see conditional probability theory and conditional probability visualizations.

Bayes' Theorem reverses the conditioning in total probability problems. After computing P(B) using total probability, Bayes' theorem finds P(Aᵢ|B). These theorems work as a pair in many applications. Learn more at Bayes' theorem calculator and Bayes' theorem examples.

Independence provides an important special case. When B is independent of the partition, P(B|Aᵢ) equals P(B) for all i, and total probability simplifies to P(B) = Σ P(Aᵢ)·P(B) = P(B). Explore independence at independent events and testing independence.

Probability distributions can be analyzed using total probability by conditioning on parameter values or mixture components. See mixture distributions and conditional distributions for applications in statistical modeling.

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.