Joint, Marginal, and Conditional Distributions
Keep several random variables together with a joint distribution, remove variables by marginalizing, and restrict known information by conditioning. Use the product rule and total probability to move between these views.
A joint distribution describes several random variables within the same experiment. From it, we can ignore a variable by marginalizing or use a known value by conditioning. These operations answer different questions and retain different amounts of information about how the variables vary together.
Build a Joint Distribution from Paired Observations
Suppose a weather station records two variables each morning:
- if it rains and otherwise;
- if the wind is strong and otherwise.
Across 100 mornings, the paired counts are:
| Row total | |||
|---|---|---|---|
| 50 | 20 | 70 | |
| 10 | 20 | 30 | |
| Column total | 60 | 40 | 100 |
Dividing every count by gives the joint probability mass function:
| Row total | |||
|---|---|---|---|
| Column total |
For discrete random variables and , write:
Each cell assigns probability to one ordered pair. For example, is the probability of rain without strong wind. A valid joint mass function is nonnegative and sums to one over every possible pair:
The order of the variables must remain clear. The pair is not the same label as .
Exercise: Read a joint probability from a table
Using the weather table, what is ?
Compute it first, then check your number.
HintFind one cell, not a row or column total
Locate the row and the column .
SolutionRead the probability assigned to the ordered pair
The corresponding cell is , so:
This cell represents mornings with strong wind and no rain.
Marginalization Removes a Variable
Suppose we want the distribution of rain without keeping track of wind. Add across every possible wind value:
“The marginal mass at equals the sum of the joint masses at over every possible .” The sum removes while retaining .
For rainy mornings,
This is the marginal distribution of . The name comes from the row and column totals traditionally written in the margins of a table. We say that has been summed out.
Marginalization preserves the total probability for each remaining value but discards how that value was divided among values of the removed variable. From alone, we cannot recover how many rainy mornings were windy.
Exercise: Sum out one variable
Using the weather table, what is the marginal probability ?
Compute it first, then check your number.
HintAdd over every rain value
Add the two cells in the column.
SolutionAdd the column to remove rain status
Sum over and :
The marginal retains whether wind is strong but no longer records whether it rained.
Conditioning Keeps a Slice and Renormalizes It
Now suppose we know that it rained. The row contains the relevant joint probabilities, but its total is , not one. Divide each cell in that row by the row total:
Therefore:
The two conditional probabilities sum to one. Marginalization removed by adding over it; conditioning fixes at one value and rescales the selected slice.
Exercise: Normalize a selected table slice
Using the weather table, calculate .
Compute it first, then check your number.
HintUse the strong-wind column as the conditioned group
The joint cell is , and the column total is .
SolutionDivide the selected cell by its column total
Restrict attention to mornings with strong wind:
Half of the strongly windy mornings are rainy in this model.
A Joint Distribution Retains Dependence
The two marginals do not generally determine the joint distribution. In the weather model:
If rain and strong wind were independent, their joint probability would be:
The actual joint probability is . The difference records an association that cannot be seen from either marginal alone. Many distinct joint tables can have the same row and column totals while arranging probability differently inside the table.
Exercise: Detect information lost by marginalization
Suppose you know only that and . Can you determine without an independence assumption or other joint information?
Select one choice, then check.
HintAsk whether multiplication is always valid
The product equals the joint probability only under an independence condition.
SolutionRetain the missing dependence information
No. The marginals specify the row and column totals, but probability can be arranged inside those totals in different ways. An independence assumption would select , while the displayed weather model uses .
Factor the Joint Distribution
The definition of conditional probability can be rearranged into the product rule:
The order can also be reversed:
For the rainy-and-windy cell, both routes give the same joint probability:
and:
A joint distribution is therefore equivalent to a marginal distribution for one variable together with a conditional distribution for the other.
Exercise: Reconstruct a joint probability
Suppose and . What is ?
Compute it first, then check your number.
HintUse a marginal and a conditional factor
Multiply by .
SolutionApply the product rule
The joint probability is:
We first enter the group where , which has probability . Within that group, of the probability also has , leaving joint probability .
More Variables Give More Possible Factorizations
For three variables, repeated use of the product rule gives:
For variables, the probability chain rule is:
“The joint mass of the complete sequence equals the mass of the first value, multiplied by each later value’s probability given every value that came before it in the chosen order.” No independence assumption is being made.
This identity does not assume independence. It expresses one joint probability as a sequence of conditional probabilities. A different variable order gives a different-looking but equally valid factorization.
Autoregressive language models apply this identity to a token sequence:
The model estimates the conditional factors; multiplying them gives the joint probability assigned to the complete sequence.
Exercise: Evaluate a three-variable chain factorization
Suppose , , and . What is ?
Compute it first, then check your number.
HintMultiply in the stated order
Use .
SolutionMultiply the conditional stages
The chain rule gives:
Each factor conditions on the values that appear earlier in the chosen ordering.
Total Probability Recovers a Marginal
Combining the product rule with marginalization gives:
For rain:
The marginal is a weighted average of the conditional probabilities across all possible values of the removed variable.
Sums Become Integrals for Continuous Variables
If and are continuous, a joint density assigns density over the plane. Probabilities come from integrating over regions rather than reading individual point values:
Marginal density is obtained by integrating out the other variable:
Where , conditional density is:
The same three operations remain: keep variables jointly, integrate one out, or fix known information and renormalize. As with any continuous density, is not the probability of one exact point.
See What Each Operation Retains
The following experiment starts with a joint probability table. Its heatmap shows the paired structure, while the adjacent bars show the two marginals. Change the interior probabilities while keeping the total equal to one and observe how a joint distribution can change even when a marginal changes only slightly.
Inspect a joint table and its marginals
Edit the joint probabilities, keeping them nonnegative with total one. Compare the heatmap with the row and column sums.
Ready to run.
Exercise: Distinguish marginalization from conditioning
Which operation produces ?
Select one choice, then check.
HintLook at the range of the sum
The formula includes every possible value of , rather than selecting one.
SolutionSum out the variable that is no longer needed
This is marginalization. Adding over every preserves the total probability associated with while discarding which value accompanied it.
Before Moving between Distribution Views
State which variables remain and which information is being removed or fixed. A joint distribution retains paired structure. A marginal sums or integrates a variable out and may lose dependence information. A conditional distribution selects a value or event and renormalizes the remaining variable. Check that every resulting distribution is nonnegative and normalized.
The next lesson studies independence. It identifies the special case in which the joint distribution factors into a product of marginals and conditioning on one variable does not change the distribution of the other.