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

Bayes' Theorem Formula and Components

Derive Bayes' Theorem from conditional probability and identify the prior, likelihood, and posterior.

Bayes' Theorem Formula and Components

What you'll learn: How to derive Bayes' Theorem from conditional probability and identify its three key components: prior, likelihood, and posterior.

The Core Idea

Bayes' Theorem is a way to reverse conditional probabilities—it lets you flip P(A|B) into P(B|A). This seemingly simple reversal is incredibly powerful for updating beliefs when new evidence arrives.

Deriving Bayes' Theorem

You already know the multiplication rule: P(A and B) = P(A|B) × P(B)

You can also write it the other way: P(A and B) = P(B|A) × P(A)

Since both equal P(A and B), we can set them equal:

P(A|B) × P(B) = P(B|A) × P(A)

Solve for P(B|A):

P(B|A) = [P(A|B) × P(A)] / P(B)

That's Bayes' Theorem!

The Three Components

Each piece has a special name:

  • Prior: P(A) — Your initial belief about A before seeing evidence B
  • Likelihood: P(B|A) — How probable the evidence B is if A is true
  • Posterior: P(B|A) — Your updated belief about A after observing evidence B

The denominator P(B) is sometimes called the "marginal probability" or "normalizing constant."

An Analogy

Think of medical testing:

  • Prior: How common is the disease in the population?
  • Likelihood: If someone has the disease, how likely is a positive test?
  • Posterior: Given a positive test, what's the probability they actually have the disease?

Bayes' Theorem combines these pieces to answer questions you couldn't answer with conditional probability alone.

Key Takeaway: Bayes' Theorem reverses conditional probabilities using the formula P(B|A) = [P(A|B) × P(A)] / P(B), where P(A) is the prior, P(A|B) is the likelihood, and P(B|A) is the posterior.