Course contentsShow
← Data Science
Lesson 97 of 2,1453. Probability FoundationsFree lesson

Law of Total Probability

Learn to decompose P(A) across partitions: P(A) = Σ P(A|Bᵢ)×P(Bᵢ) for mutually exclusive Bᵢ.

What You'll Learn

You'll learn how to break down a complex probability by dividing the sample space into simpler, non-overlapping pieces—a powerful technique for calculating probabilities when direct computation is hard.

The Core Idea

The Law of Total Probability lets you find P(A) by "going through" all possible scenarios (called a partition) that could lead to A.

Imagine you want to know the probability it rains today, but weather depends heavily on the season. Instead of calculating directly, you can break it down:

  • P(Rain) = P(Rain|Winter)×P(Winter) + P(Rain|Spring)×P(Spring) + P(Rain|Summer)×P(Summer) + P(Rain|Fall)×P(Fall)

The seasons form a partition: they're mutually exclusive (can't be two seasons at once) and collectively exhaustive (it's always one of them).

The Formula

If B₁, B₂, ..., Bₙ form a partition of the sample space, then:

P(A) = P(A|B₁)×P(B₁) + P(A|B₂)×P(B₂) + ... + P(A|Bₙ)×P(Bₙ)

Or more compactly: P(A) = Σ P(A|Bᵢ)×P(Bᵢ)

When to Use It

Use this law when:

  • You know conditional probabilities P(A|Bᵢ) but not P(A) directly
  • You can naturally divide the sample space into mutually exclusive, collectively exhaustive scenarios
  • You're working backwards from conditions to an overall probability

Example

A factory has three machines (B₁, B₂, B₃) producing 30%, 45%, and 25% of items respectively. Their defect rates are 2%, 3%, and 5%. What's the overall defect probability?

P(Defect) = P(Defect|B₁)×P(B₁) + P(Defect|B₂)×P(B₂) + P(Defect|B₃)×P(B₃)
P(Defect) = (0.02×0.30) + (0.03×0.45) + (0.05×0.25) = 0.032 or 3.2%

Key Takeaway: The Law of Total Probability decomposes a probability by conditioning on a partition—each piece weighted by how likely that scenario is.