01 / 20
B A

Bayes' Rule
Updating Beliefs with Evidence

Learn how to reverse conditional probabilities and compute the probability of a hypothesis given observed data using the most powerful tool in probability theory.

College Statistics

What is Conditional Probability?

Conditional probability measures the likelihood of an event given that another event has already occurred. It is the foundation of Bayes' Rule.

\( P(A \mid B) \)
Probability of A, knowing B happened
\( P(A \cap B) \)
Joint probability: both A and B occur
\( P(B) \)
Marginal probability of the given event

The Big Question Bayes Answers

In many real situations, we know \( P(B \mid A) \) but actually need \( P(A \mid B) \). Bayes' Rule lets us flip the conditioning.

What We Know
\( P(\text{evidence} \mid \text{cause}) \)
Bayes What We Want
\( P(\text{cause} \mid \text{evidence}) \)

Prior, Likelihood, and Posterior

Bayes' Rule connects three key ingredients. Understanding each one is essential before applying the formula.

Prior
\( P(A) \): your initial belief about A before seeing any data.
Likelihood
\( P(B \mid A) \): how likely the data B is if A is true.
Posterior
\( P(A \mid B) \): your updated belief about A after seeing data B.

Bayes' Rule: The Formula

\( P(A \mid B) \)
Posterior: what we want
\( P(B \mid A) \)
Likelihood: data given hypothesis
\( P(A) \)
Prior: initial belief
\( P(B) \)
Evidence: total probability of data

Expanding \( P(B) \) with the Law of Total Probability

Often \( P(B) \) is not given directly. We compute it by summing over all ways B can occur, partitioned by whether A is true or not.

Here \( A^c \) denotes "not A". This expanded version is what you will use in most textbook problems.

Visualizing with a Probability Tree

Start
\( P(A) \)
A
\( P(A^c) \)
\( A^c \)
\( P(B \mid A) \)
\( A \cap B \)
\( P(B^c \mid A) \)
\( A \cap B^c \)
\( P(B \mid A^c) \)
\( A^c \cap B \)
\( P(B^c \mid A^c) \)
\( A^c \cap B^c \)
\( P(B) \)

\( P(A \mid B) \) vs \( P(B \mid A) \)

The most common source of confusion: these two conditional probabilities are not the same, and confusing them is called the inverse fallacy.

\( P(B \mid A) \) \( P(A \mid B) \)
Name Likelihood Posterior
Reads as "Prob of data given hypothesis" "Prob of hypothesis given data"
Medical example P(+test | disease) P(disease | +test)
Typically Given in the problem What you solve for

Step-by-Step Application

1
Identify the hypothesis and data. What is A (hypothesis)? What is B (observed data)?
2
Find the prior \( P(A) \). This is the base rate: how common is A in the population?
3
Find the likelihood \( P(B \mid A) \). How probable is the data if A is true?
4
Find \( P(B \mid A^c) \). How probable is the data if A is not true (false positive rate)?
5
Compute \( P(B) \) using the Law of Total Probability, then plug everything into Bayes' Rule.

Example 1: Medical Testing

A disease affects 1% of the population. A test has a sensitivity of 95% and a false positive rate of 3%. If a patient tests positive, what is \( P(\text{disease} \mid +) \)?

Interpreting the Result

Even with a 95% accurate test, a positive result only gives about a 24.2% chance of actually having the disease. Why so low?

10,000 People 100 Diseased 95 True + 9,900 Healthy 297 False + 9,603 True − Total positives: 95 + 297 = 392 → Only 95 / 392 ≈ 24.2% truly have disease

Example 2: Email Spam Filter

Suppose 40% of emails are spam. 90% of spam emails contain the word "free", while only 5% of legitimate emails do. If an email contains "free", what is the probability it is spam?

An email containing "free" has about a 92.3% chance of being spam: the high prior (40%) and strong likelihood (90%) reinforce each other.

Example 3: Manufacturing Defects

A factory has two machines. Machine A produces 60% of items and has a 2% defect rate. Machine B produces 40% and has a 5% defect rate. A defective item is found: what is the probability it came from Machine B?

There is a 62.5% chance the defective item came from Machine B, even though Machine B only makes 40% of items: its higher defect rate shifts the posterior.

Common Mistakes

✕ Inverse Fallacy
Assuming \( P(A \mid B) = P(B \mid A) \). These are generally very different quantities.
✕ Ignoring the Prior
Forgetting \( P(A) \). A rare disease (low prior) dramatically lowers the posterior even with a good test.
✕ Wrong \( P(B) \)
Forgetting to expand \( P(B) \) using the Law of Total Probability. You need both branches.

Summary Cheat Sheet

Component Symbol Role in Bayes' Rule
Prior \( P(A) \) Base rate of hypothesis
Likelihood \( P(B \mid A) \) How well data fits hypothesis
Evidence \( P(B) \) Normalizing constant (denominator)
Posterior \( P(A \mid B) \) Updated belief (what we solve for)
Complement likelihood \( P(B \mid A^c) \) False positive / alternative explanation rate

Question 1 of 5

In Bayes' Rule \( P(A \mid B) = \frac{P(B \mid A)\,P(A)}{P(B)} \), what does \( P(A) \) represent?

Question 2 of 5

A disease has prevalence \( P(D) = 0.02 \). A test has sensitivity \( P(+ \mid D) = 0.90 \) and false positive rate \( P(+ \mid D^c) = 0.05 \). What is \( P(+) \)?

Question 3 of 5

Using the values from Question 2, what is \( P(D \mid +) \), the probability a person who tests positive actually has the disease?

Question 4 of 5

If the prior probability \( P(A) \) increases while \( P(B \mid A) \) and \( P(B \mid A^c) \) stay fixed, what happens to the posterior \( P(A \mid B) \)?

Question 5 of 5

30% of students study the night before an exam. Of those who study, 85% pass. Of those who don't study, 40% pass. A student passed: what is \( P(\text{studied} \mid \text{passed}) \)?