01 / 20

Conditional Distributions
& Marginalization

Master how to extract conditional probabilities from joint distributions and recover marginal distributions by summing or integrating out variables.

Statistics

What Is a Joint Distribution?

A joint distribution describes the probability of two (or more) random variables taking on specific values simultaneously. For discrete variables \(X\) and \(Y\), the joint probability mass function is \(P(X = x, Y = y)\).

Discrete
\(P(X\!=\!x,\, Y\!=\!y)\) is a probability table summing to 1
Continuous
\(f_{X,Y}(x,y)\) is a density; integrate over \(\mathbb{R}^2\) to get 1

A Joint Probability Table

Consider two dice: \(X\) = the face of die 1 (simplified to Low/High) and \(Y\) = the face of die 2 (Low/High). Each cell holds \(P(X\!=\!x, Y\!=\!y)\).

\(Y = \text{Low}\) \(Y = \text{High}\) \(P(X)\)
\(X = \text{Low}\) 0.25 0.25 0.50
\(X = \text{High}\) 0.25 0.25 0.50
\(P(Y)\) 0.50 0.50 1.00

Recovering the Marginal Distribution

Marginalization is the process of summing (or integrating) a joint distribution over one variable to obtain the distribution of the other variable alone.

Discrete
$$P(X = x) = \sum_{y} P(X = x, Y = y)$$
Continuous
$$f_X(x) = \int_{-\infty}^{\infty} f_{X,Y}(x,y)\,dy$$

Marginalization as Projection

0.15 0.35 0.10 0.40
\(X=0\)
\(X=1\)
\(Y=0\)
\(Y=1\)
0.50 0.50
\(P(X)\)
0.25 0.75
\(P(Y)\)
1.00

The Conditional Distribution

A conditional distribution tells us the probability of one variable given that we know the value of another. It answers: "Now that I know \(Y = y\), what does the distribution of \(X\) look like?"

Discrete
$$P(X = x \mid Y = y) = \frac{P(X = x,\, Y = y)}{P(Y = y)}$$
Continuous
$$f_{X \mid Y}(x \mid y) = \frac{f_{X,Y}(x,y)}{f_Y(y)}$$

Core Rule: Law of Total Probability

The Law of Total Probability connects conditionals and marginals. It formalizes how you "un-condition" to recover the marginal.

This is precisely marginalization rewritten: the joint factors as conditional times marginal, and summing recovers the other marginal.

How Joint, Marginal, and Conditional Connect

Joint \(P(X, Y)\)
sum over \(Y\)
sum over \(X\)
Marginal \(P(X)\)
Marginal \(P(Y)\)
divide by marginal
Conditional \(P(X \mid Y)\)

Marginal vs. Conditional

Marginal Conditional
Notation \(P(X)\) or \(f_X(x)\) \(P(X \mid Y\!=\!y)\) or \(f_{X|Y}(x|y)\)
What it tells you Distribution of \(X\) alone Distribution of \(X\) given \(Y\!=\!y\)
Obtained by Summing/integrating out \(Y\) Dividing joint by \(P(Y\!=\!y)\)
Sums/integrates to 1 1 (for each fixed \(y\))
Depends on \(y\)? No Yes: different \(y\) gives different distribution

How to Compute Conditionals & Marginals

1
Write the joint. Start with the joint distribution \(P(X, Y)\) or \(f_{X,Y}(x,y)\), whether given as a table, formula, or data.
2
Marginalize. Sum (discrete) or integrate (continuous) over the variable you want to eliminate: \(P(Y\!=\!y) = \sum_x P(X\!=\!x, Y\!=\!y)\).
3
Condition. Divide each joint entry by the marginal of the conditioning variable: \(P(X\!=\!x \mid Y\!=\!y) = P(X\!=\!x,Y\!=\!y) / P(Y\!=\!y)\).
4
Verify. Check that the conditional distribution sums to 1 over all values of the unconditioned variable.

Example 1: Discrete Table

Survey data: \(X\) = Exercises (Yes/No), \(Y\) = Healthy weight (Yes/No).

\(Y = \text{Yes}\) \(Y = \text{No}\) \(P(X)\)
\(X = \text{Yes}\) 0.36 0.14 0.50
\(X = \text{No}\) 0.22 0.28 0.50
\(P(Y)\) 0.58 0.42 1.00

Example 1: Full Conditional

Let us find the complete conditional distribution \(P(Y \mid X = \text{Yes})\).

1
Marginal of X = Yes: \(P(X\!=\!\text{Yes}) = 0.36 + 0.14 = 0.50\)
2
Conditional for Y = Yes: \(0.36 / 0.50 = \) 0.72
3
Conditional for Y = No: \(0.14 / 0.50 = \) 0.28
4
Verify: \(0.72 + 0.28 = 1.00\) ✓

Example 2: Continuous Joint

Suppose \(f_{X,Y}(x,y) = 6(1-y)\) for \(0 \le x \le y \le 1\), and 0 otherwise. Find \(f_X(x)\) and \(f_{Y \mid X}(y \mid x)\).

1
Marginalize out \(Y\): For a given \(x\), \(y\) ranges from \(x\) to 1: $$f_X(x) = \int_x^1 6(1-y)\,dy = 6\!\left[\,y - \tfrac{y^2}{2}\right]_x^1 = 3(1-x)^2$$
2
Conditional density: $$f_{Y \mid X}(y \mid x) = \frac{6(1-y)}{3(1-x)^2} = \frac{2(1-y)}{(1-x)^2}, \quad x \leq y \leq 1$$
3
Verify: \(\displaystyle\int_x^1 \frac{2(1-y)}{(1-x)^2}\,dy = 1\) ✓

Example 3: Bayes via Marginalization

A disease has prevalence \(P(D) = 0.01\). A test has sensitivity \(P(+ \mid D) = 0.95\) and specificity \(P(- \mid D^c) = 0.90\). Find \(P(D \mid +)\).

1
Marginalize for \(P(+)\) using the law of total probability: $$P(+) = P(+\mid D)\,P(D) + P(+\mid D^c)\,P(D^c)$$ $$= (0.95)(0.01) + (0.10)(0.99) = 0.1085$$
2
Apply Bayes' theorem: $$P(D \mid +) = \frac{P(+\mid D)\,P(D)}{P(+)} = \frac{0.0095}{0.1085} \approx 0.0876$$

Common Mistakes

✕ Dividing by the Wrong Marginal
For \(P(X \mid Y)\), divide by \(P(Y)\), not \(P(X)\). The conditioning variable goes in the denominator.
✕ Forgetting to Verify Sum = 1
A conditional distribution must sum/integrate to 1 over the unconditioned variable. Always check this.
✕ Confusing Joint with Conditional
\(P(X, Y) \neq P(X \mid Y)\). The joint is a number; the conditional is a rescaled slice of the joint.

Summary of Key Formulas

Operation Discrete Continuous
Marginal of \(X\) \(\displaystyle\sum_y P(X,Y)\) \(\displaystyle\int f_{X,Y}\,dy\)
Conditional of \(X \mid Y\) \(\dfrac{P(X,Y)}{P(Y)}\) \(\dfrac{f_{X,Y}}{f_Y}\)
Product Rule \(P(X,Y) = P(X\mid Y)\,P(Y)\) \(f_{X,Y} = f_{X\mid Y}\cdot f_Y\)
Law of Total Prob. \(\displaystyle\sum_y P(X\mid Y)\,P(Y)\) \(\displaystyle\int f_{X\mid Y}\,f_Y\,dy\)
Bayes' Theorem \(\dfrac{P(Y\mid X)\,P(X)}{P(Y)}\) \(\dfrac{f_{Y\mid X}\,f_X}{f_Y}\)

Question 1 of 5

Given a joint PMF table where \(P(X\!=\!1,\,Y\!=\!2) = 0.12\) and the marginal \(P(Y\!=\!2) = 0.40\), what is \(P(X\!=\!1 \mid Y\!=\!2)\)?

Question 2 of 5

To find the marginal distribution \(P(X)\) from a joint distribution \(P(X, Y)\), you should:

Question 3 of 5

If \(X\) and \(Y\) are independent, which of the following must be true?

Question 4 of 5

Given \(f_{X,Y}(x,y) = 2\) for \(0 < x < y < 1\) (and 0 otherwise), what is \(f_X(x)\)?

Question 5 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\). Using Bayes' theorem, approximately what is \(P(D \mid +)\)?