Law of Total Probability: Formula, Examples & Applications

4 fully solved examples and 3 practice problems on partitioning complex probabilities

Understanding the Law of Total Probability

The Law of Total Probability is a fundamental identity that breaks a complex probability into a weighted sum of simpler conditional probabilities. It applies when the sample space \( S \) is partitioned into \( n \) mutually exclusive, collectively exhaustive events \( E_1, E_2, \ldots, E_n \) and we want the total probability of some event \( A \) that overlaps with those partitions.

Venn diagram showing a sample space partitioned into disjoint events E₁ through Eₙ, with event A intersecting several of them
Figure 1 — A partition \( \{E_1, \ldots, E_n\} \) of the sample space with \( A \) overlapping several partitions.

Deriving the Formula

Since the \( E_i \) partition \( S \), event \( A \) is the union of its intersections with each \( E_i \):

\[ A = (A \cap E_1) \cup (A \cap E_2) \cup \cdots \cup (A \cap E_n) \]

Because the \( E_i \) are mutually exclusive, so are the pieces \( A \cap E_i \). Additivity of probability gives:

\[ P(A) = P(A \cap E_1) + P(A \cap E_2) + \cdots + P(A \cap E_n) \]

Applying the definition of conditional probability \( P(A \cap E_i) = P(A \mid E_i)\,P(E_i) \) yields the final rule:

Law of Total Probability formula
Rule Formula
Law of Total Probability \( P(A) = \displaystyle\sum_{i=1}^{n} P(A \mid E_i)\,P(E_i) \)

Because the \( E_i \) are collectively exhaustive, \( \sum_{i=1}^{n} P(E_i) = 1 \). The formula works for any \( n \ge 2 \); the simplest case \( n = 2 \) uses \( E_1, E_2 \) with \( E_2 = E_1^c \), so \( P(A) = P(A \mid E_1)P(E_1) + P(A \mid E_1^c)P(E_1^c) \).


Solved Examples: Applying the Law

Example 1 — Random selection from three bags

Three bags each contain 4 colored balls:

  • Bag B1: 2 red, 2 blue
  • Bag B2: 3 red, 1 blue
  • Bag B3: 1 red, 3 blue

A bag is chosen at random, and then one ball is drawn at random from it. What is the probability the ball is red?

Diagram of three bags, each with four balls showing the red/blue composition
Figure 2 — Three bags with different red/blue compositions.
View solution

Method 1 — Pooling (valid only because bags are equally likely and same size): Total 12 balls, 6 red:

\[ P(\text{red}) = \frac{6}{12} = \frac{1}{2} \]

Method 2 — Law of Total Probability. Let \( E_i \) = "Bag \( B_i \) chosen" and \( A \) = "red ball drawn":

\[ P(E_1) = P(E_2) = P(E_3) = \tfrac{1}{3} \] \[ P(A \mid E_1) = \tfrac{2}{4} = \tfrac{1}{2}, \quad P(A \mid E_2) = \tfrac{3}{4}, \quad P(A \mid E_3) = \tfrac{1}{4} \] \[ P(A) = \tfrac{1}{2}\cdot\tfrac{1}{3} + \tfrac{3}{4}\cdot\tfrac{1}{3} + \tfrac{1}{4}\cdot\tfrac{1}{3} = \tfrac{2}{12} + \tfrac{3}{12} + \tfrac{1}{12} = \tfrac{6}{12} = \tfrac{1}{2} \]

Example 2 — Test pass rates by gender

A class is 40% male and 60% female. Historically, 50% of males and 70% of females pass the test. What fraction of the class passes?

Diagram of a class split into 40% male and 60% female, with 50% and 70% pass rates respectively
Figure 3 — Class split by gender with corresponding pass rates.
View solution

Let \( E_1 \) = male, \( E_2 \) = female, \( A \) = passes.

\[ P(E_1) = 0.40, \quad P(E_2) = 0.60 \] \[ P(A \mid E_1) = 0.50, \quad P(A \mid E_2) = 0.70 \] \[ P(A) = 0.50 \cdot 0.40 + 0.70 \cdot 0.60 = 0.20 + 0.42 = 0.62 \]

Answer: 62% of the class passes.

Example 3 — Factory production with quality-control target

Three factories A, B, C supply a market. Factory A produces 30% of all tools; B and C together produce the remaining 70%. The non-defective rates are 98% (A), 95% (B), and 97% (C). What shares should B and C produce so that the overall non-defective rate is exactly 96%?

Diagram of three factories with their non-defective rates and shares of total production
Figure 4 — Three-factory production with quality-control target.
View solution

Let \( x = P(B) \) and \( y = P(C) \). Since A, B, C partition the market:

\[ P(A) = 0.30, \quad x + y = 0.70 \implies y = 0.70 - x \]

With \( ND \) = "non-defective":

\[ P(ND \mid A) = 0.98, \quad P(ND \mid B) = 0.95, \quad P(ND \mid C) = 0.97 \]

Set the target \( P(ND) = 0.96 \) and expand:

\[ 0.96 = 0.98 \cdot 0.30 + 0.95\,x + 0.97\,(0.70 - x) \] \[ 0.96 = 0.294 + 0.95x + 0.679 - 0.97x \] \[ 0.96 = 0.973 - 0.02x \] \[ 0.02x = 0.013 \implies x = 0.65 \] \[ y = 0.70 - 0.65 = 0.05 \]

Answer: Factory B should produce 65%, Factory C 5%.

Check: \( 0.98(0.30) + 0.95(0.65) + 0.97(0.05) = 0.294 + 0.6175 + 0.0485 = 0.96 \) ✓

Example 4 — Medical testing accuracy

5% of a population has the flu. A rapid test is 95% sensitive (true positive rate) and has a 1% false-positive rate for healthy individuals. What is the overall probability that a randomly selected person tests positive?

View solution

Let \( E_1 \) = has flu, \( E_2 \) = healthy, \( A \) = tests positive:

\[ P(E_1) = 0.05, \quad P(E_2) = 0.95 \] \[ P(A \mid E_1) = 0.95, \quad P(A \mid E_2) = 0.01 \] \[ P(A) = 0.95 \cdot 0.05 + 0.01 \cdot 0.95 = 0.0475 + 0.0095 = 0.057 \]

Answer: 5.7%.


Practice Problems

Practice 1 — Two urns

Urn A has 3 red and 2 black marbles. Urn B has 1 red and 4 black marbles. An urn is chosen at random, and a marble drawn. What is the probability the marble is red?

Answer
\[ P(\text{red}) = \tfrac{3}{5}\cdot\tfrac{1}{2} + \tfrac{1}{5}\cdot\tfrac{1}{2} = \tfrac{3}{10} + \tfrac{1}{10} = \tfrac{4}{10} = \tfrac{2}{5} \]

Practice 2 — Defect rate from two machines

Machine 1 produces 60% of the output with a 3% defect rate; Machine 2 produces the rest with a 1% defect rate. What is the overall defect rate?

Answer
\[ P(D) = 0.60 \cdot 0.03 + 0.40 \cdot 0.01 = 0.018 + 0.004 = 0.022 \]

Answer: 2.2%.

Practice 3 — Inverse problem

A company's three plants produce 50%, 30%, and 20% of its output, with defect rates 2%, 3%, and 5%. A part is selected at random. What is the overall defect rate? If a defective part is found, what is the probability it came from the third plant? (Hint: you'll need Bayes' Theorem.)

Answer
\[ P(D) = 0.50(0.02) + 0.30(0.03) + 0.20(0.05) = 0.010 + 0.009 + 0.010 = 0.029 \]

By Bayes' Theorem:

\[ P(\text{plant 3} \mid D) = \frac{0.20 \times 0.05}{0.029} = \frac{0.010}{0.029} \approx 0.345 \]

Frequently Asked Questions

What is the Law of Total Probability?

Given a partition of the sample space into mutually exclusive and exhaustive events \(E_1, \ldots, E_n\), for any event \(A\): \(P(A) = \sum_i P(A \mid E_i)\,P(E_i)\). It breaks a complex probability into a weighted sum of simpler conditional probabilities.

What is a partition of a sample space?

A partition is a collection of events \(E_1, \ldots, E_n\) that are (1) mutually exclusive — no two can occur at once, so \(E_i \cap E_j = \varnothing\) for \(i \ne j\) — and (2) collectively exhaustive — their union covers all of \(S\), so \(E_1 \cup \cdots \cup E_n = S\). For a partition, \(\sum_i P(E_i) = 1\).

How is the Law of Total Probability related to Bayes' Theorem?

The Law of Total Probability supplies the denominator of Bayes' Theorem. Bayes is \(P(E_i \mid A) = P(A \mid E_i)\,P(E_i)/P(A)\), and \(P(A)\) is exactly \(\sum_j P(A \mid E_j)\,P(E_j)\).

When should I use the Law of Total Probability?

Use it when \(A\)'s overall probability depends on which of several scenarios occurred, and you know both the probability of each scenario and \(A\)'s conditional probability on each scenario. Common cases: mixing pools (bags, urns), stratified populations (gender, age groups), manufacturing (multiple factories), and diagnostics (diseased vs. healthy).

Related Probability Resources

Last updated: October 20, 2026