Many questions involve two random variables at once: the number of heads and the number of tails, a customer's age group and spending. A two-way table, like those in conditional probability from two-way tables, holds their joint distribution, and the pmf of each variable alone sits in its margins.
Key idea
The joint pmf is $p(x, y) = P(X = x, Y = y)$; its cells are nonnegative and add to 1. The marginal pmfs come from adding across: $$p_X(x) = \sum_y p(x, y), \qquad p_Y(y) = \sum_x p(x, y).$$ Any event about $(X, Y)$ has probability equal to the sum of its cells.
Why it works
The event $\{X = x\}$ splits into the disjoint pieces $\{X = x, Y = y\}$, one for each value $y$, so by the addition axiom $P(X = x)$ is the sum of that column. That is why these are called marginal: they were written in the margins of the table. The marginals do not determine the table, since many different tables have the same row and column totals; the joint pmf carries more information than the two marginals together.
| $X = 0$ | $X = 1$ | $X = 2$ | $P(Y = y)$ | |
|---|---|---|---|---|
| $Y = 0$ | $\frac{1}{6}$ | $\frac{1}{6}$ | $0$ | $\frac{1}{3}$ |
| $Y = 1$ | $\frac{1}{12}$ | $\frac{1}{4}$ | $\frac{1}{3}$ | $\frac{2}{3}$ |
| $P(X = x)$ | $\frac{1}{4}$ | $\frac{5}{12}$ | $\frac{1}{3}$ | $1$ |
Worked examples
Worked example: Marginals
From the table, find $P(X = 1)$ and $P(Y = 1)$.
- $P(X = 1)$ adds the column $X = 1$: $\frac{1}{6} + \frac{1}{4} = \frac{5}{12}$.
- $P(Y = 1)$ adds the row $Y = 1$: $\frac{1}{12} + \frac{1}{4} + \frac{1}{3} = \frac{2}{3}$.
Answer: $\frac{5}{12}$ and $\frac{2}{3}$
Worked example: An event about both
From the table, find $P(X + Y \le 1)$ and $E[X]$.
- The cells with $x + y \le 1$ are $(0, 0)$, $(1, 0)$ and $(0, 1)$: $\frac{1}{6} + \frac{1}{6} + \frac{1}{12} = \frac{5}{12}$.
- $E[X]$ uses the marginal of $X$: $0 \cdot \frac{1}{4} + 1 \cdot \frac{5}{12} + 2 \cdot \frac{1}{3} = \frac{13}{12}$.
Answer: $\frac{5}{12}$ and $\frac{13}{12}$
A missing cell can be recovered from a margin: if you know $P(X = 2) = \frac{1}{3}$ and the cell $(2, 0)$ is 0, then the cell $(2, 1)$ must be $\frac{1}{3}$. Every row and every column adds to its marginal.
Common mistake
Reading one cell as a marginal: $P(X = 1, Y = 1) = \frac{1}{4}$ is not $P(X = 1)$, which also includes the cases with $Y = 0$. Check: a marginal must be at least as large as every cell in its row or column.