01 / 21

Conditional Probability
& Expectation

Master the foundations of conditional probability and conditional expectation: how new information reshapes uncertainty and refines predictions.

Statistics

What Is Conditional Probability?

Conditional probability measures the likelihood of an event given that another event has already occurred. It answers: "How does knowing \(B\) happened change the probability of \(A\)?"

The denominator restricts the sample space to outcomes where \(B\) occurs, and the numerator counts only those outcomes that also satisfy \(A\).

Visualizing \(P(A \mid B)\)

S (Sample Space) A B
\(A \cap B\)
Numerator Denominator

Why Conditioning Matters

Medical Testing
A positive test result doesn't mean certain disease: \(P(\text{disease} \mid +)\) depends on the base rate.
Machine Learning
Bayesian classifiers compute \(P(\text{class} \mid \text{features})\) to make predictions from data.
Finance
Risk models estimate \(P(\text{default} \mid \text{recession})\) to price credit derivatives.

Conditional probability is the backbone of Bayesian inference, decision theory, and virtually every applied statistics problem.

The Multiplication Rule

A natural extension to multiple events yields the chain rule:

This chain rule is central to modeling sequential processes such as Markov chains and language models.

Bayes' Theorem

Prior
\(P(A)\)
Likelihood
\(P(B \mid A)\)
Posterior
\(P(A \mid B)\)
Normalize by \(P(B)\) = total evidence

Bayes' Theorem updates our prior belief \(P(A)\) using new evidence \(P(B \mid A)\) to produce a posterior \(P(A \mid B)\).

Law of Total Probability

\(B_1\)
\(B_2\)
\(B_3\)
A
\(P(A \mid B_1)P(B_1)\)
\(P(A \mid B_2)P(B_2)\)
\(P(A \mid B_3)P(B_3)\)

The total probability of \(A\) is obtained by summing its conditional probability across each partition slice, weighted by that slice's probability.

Independence vs Dependence

Independent Dependent
Definition \(P(A \mid B) = P(A)\) \(P(A \mid B) \neq P(A)\)
Joint prob. \(P(A \cap B) = P(A)P(B)\) \(P(A \cap B) = P(A \mid B)P(B)\)
Intuition Knowing \(B\) tells nothing about \(A\) Knowing \(B\) changes our belief about \(A\)
Example Two fair coin flips Drawing cards without replacement

What Is Conditional Expectation?

Just as conditional probability restricts the sample space, conditional expectation computes the expected value of a random variable using a conditional distribution.

\(E[X \mid Y]\) is itself a random variable: it's a function of \(Y\) that gives the "best prediction" of \(X\) for each value of \(Y\).

The Tower Property

1
Inner expectation: For each value \(y\), compute \(E[X \mid Y = y]\).
2
Outer expectation: Average those conditional expectations over the distribution of \(Y\).
3
Result: You recover the unconditional \(E[X]\).

This is one of the most powerful tools in probability: it decomposes hard expectations into simpler conditional pieces.

How to Apply Conditional Reasoning

1
Identify the conditioning event: What information is "given"? Define \(B\) precisely.
2
Restrict the sample space: Recompute probabilities or expectations within the world where \(B\) holds.
3
Check for independence: If \(P(A \mid B) = P(A)\), conditioning is unnecessary: simplify.
4
Use the appropriate law: Apply Bayes' theorem, the chain rule, or the tower property as needed.
5
Verify: Check that all probabilities sum to 1 and expectations are consistent with marginals.

Example 1: Medical Test

A disease affects \(1\%\) of the population. A test has sensitivity \(95\%\) (true positive rate) and specificity \(90\%\) (true negative rate). What is \(P(\text{disease} \mid +)\)?

Example 2: Dice & Tower Property

Roll a fair die to get \(N\). Then flip \(N\) fair coins. Let \(X\) = number of heads. Find \(E[X]\).

The tower property turned a complex two-stage problem into a simple calculation.

Example 3: Eve's Law (Law of Total Variance)

Using the dice example (\(N\) = die roll, \(X\) = heads from \(N\) coins):

1
\(\text{Var}(X \mid N) = \frac{N}{4}\), so \(E[\text{Var}(X \mid N)] = \frac{E[N]}{4} = \frac{3.5}{4} = 0.875\).
2
\(E[X \mid N] = \frac{N}{2}\), so \(\text{Var}(E[X \mid N]) = \frac{1}{4}\text{Var}(N) = \frac{1}{4} \cdot \frac{35}{12} \approx 0.729\).
3
\(\text{Var}(X) = 0.875 + 0.729 \approx 1.604\).

Common Mistakes

✕ Confusing \(P(A \mid B)\) with \(P(B \mid A)\)
The "prosecutor's fallacy": these are not equal unless \(P(A) = P(B)\). Always use Bayes' theorem to invert.
✕ Ignoring the Base Rate
High sensitivity doesn't mean high \(P(D \mid +)\). The prior \(P(D)\) matters enormously.
✕ Assuming Independence
Don't use \(P(A \cap B) = P(A)P(B)\) unless independence is explicitly given or proven.

Summary of Key Formulas

Concept Formula Key Idea
Conditional Prob. \(P(A \mid B) = \frac{P(A \cap B)}{P(B)}\) Restrict sample space
Multiplication Rule \(P(A \cap B) = P(A \mid B)\,P(B)\) Joint from conditional
Bayes' Theorem \(P(A \mid B) = \frac{P(B \mid A)\,P(A)}{P(B)}\) Invert conditioning
Total Probability \(P(A) = \sum_i P(A \mid B_i)\,P(B_i)\) Marginalize over partition
Tower Property \(E[X] = E[E[X \mid Y]]\) Iterated expectation
Eve's Law \(\text{Var}(X) = E[\text{Var}(X \mid Y)] + \text{Var}(E[X \mid Y])\) Decompose variance

Question 1 of 5

If \(P(A) = 0.3\), \(P(B) = 0.5\), and \(P(A \cap B) = 0.15\), what is \(P(A \mid B)\)?

Question 2 of 5

Events \(A\) and \(B\) are independent with \(P(A) = 0.4\) and \(P(B) = 0.6\). What is \(P(A \cap B)\)?

Question 3 of 5

A disease has prevalence \(P(D) = 0.02\). A test has \(P(+ \mid D) = 0.99\) and \(P(+ \mid D^c) = 0.05\). Approximately what is \(P(D \mid +)\)?

Question 4 of 5

You roll a fair die to get \(N\), then draw \(N\) balls from an urn (with replacement), each red with probability \(\frac{1}{3}\). Let \(X\) = number of red balls. Using the tower property, what is \(E[X]\)?

Question 5 of 5

Which of the following correctly states the Law of Total Variance?