Tutorials › Statistical Theory I - Probability and Distribution Theory › Conditional Probability Tables and Marginal Checks

Conditional Distribution Theory · Tutorial 250 of 994

Conditional Probability Tables and Marginal Checks

Translate between joint probability tables and conditional pmfs, using the conditioning variable to choose the correct normalization and check.

Intermediate 9 min read

What You'll Learn

  • Read joint probabilities, marginal probabilities, and conditional pmfs from a two-way table.
  • Normalize rows or columns according to which variable is being conditioned on.
  • Convert joint table entries into conditional probabilities when the conditioning event has positive probability.
  • Reconstruct a joint table from a marginal distribution and conditional pmfs.
  • Check table totals and recognize when a conditional distribution is undefined.

Reading a Two-Way Probability Table

A two-way probability table organizes the joint distribution of two discrete random variables. Its interior entries describe probabilities of pairs of values, while its row and column totals give the corresponding marginal probabilities. Conditional probabilities come from dividing joint entries by the appropriate marginal total. The central practical question is therefore: which variable is being conditioned on, and which table total belongs to that variable?

Let \(X\) take values \(x_1,\ldots,x_r\) and \(Y\) take values \(y_1,\ldots,y_s\). Write \(p_{ij}=P(X=x_i,Y=y_j)\). In the tables below, rows index values of \(Y\), and columns index values of \(X\). Thus the row total is \(P(Y=y_j)\), and the column total is \(P(X=x_i)\).

Definition: A joint probability table has nonnegative entries \(p_{ij}=P(X=x_i,Y=y_j)\) whose grand total is \(1\). Its row total for \(Y=y_j\) is \(P(Y=y_j)=\sum_{i=1}^r p_{ij}\), and its column total for \(X=x_i\) is \(P(X=x_i)=\sum_{j=1}^s p_{ij}\). These totals are the marginal probabilities.

The arrangement matters. With \(Y\) in the rows and \(X\) in the columns, conditioning on \(Y=y_j\) means dividing entries in row \(j\) by that row's total. Conditioning on \(X=x_i\) means dividing entries in column \(i\) by that column's total. In either case, the probabilities for the variable being described must sum to \(1\), provided the conditioning event has positive probability.

From Joint Entries to Conditional PMFs

For any pair of values, the conditional probability is the joint probability divided by the probability of the conditioning event, when that event has positive probability. In a two-way table, this gives the following formulas.

$$ P(X=x_i\mid Y=y_j)=\frac{p_{ij}}{P(Y=y_j)} \quad\text{if }P(Y=y_j)>0, \qquad P(Y=y_j\mid X=x_i)=\frac{p_{ij}}{P(X=x_i)} \quad\text{if }P(X=x_i)>0. $$

The first formula divides each cell in a fixed row by that row's total. The second divides each cell in a fixed column by that column's total. A zero total cannot be used as a denominator: if \(P(Y=y_j)=0\), the conditional pmf of \(X\) given \(Y=y_j\) is not defined by this formula.

Worked Example: Calculating Both Sets of Conditionals

Suppose the joint distribution is given by this table. Rows correspond to \(Y\), columns to \(X\).

\(X=0\)\(X=1\)Row total
\(Y=a\)0.150.250.40
\(Y=b\)0.300.100.40
\(Y=c\)0.050.150.20
Column total0.500.501.00

First check the joint table: the row totals are \(0.40+0.40+0.20=1.00\), and the column totals are \(0.50+0.50=1.00\). To find the conditional pmf of \(X\) given \(Y\), divide within each row. For \(Y=a\), the entries become \(0.15/0.40=0.375\) and \(0.25/0.40=0.625\). For \(Y=b\), they are \(0.30/0.40=0.75\) and \(0.10/0.40=0.25\). For \(Y=c\), they are \(0.05/0.20=0.25\) and \(0.15/0.20=0.75\).

Each conditional row sums to \(1\): \(0.375+0.625=1\), \(0.75+0.25=1\), and \(0.25+0.75=1\).

For the conditional pmf of \(Y\) given \(X\), divide within each column. When \(X=0\), the probabilities for \(Y=a,b,c\) are \(0.15/0.50=0.30\), \(0.30/0.50=0.60\), and \(0.05/0.50=0.10\). When \(X=1\), they are \(0.25/0.50=0.50\), \(0.10/0.50=0.20\), and \(0.15/0.50=0.30\). The column checks are \(0.30+0.60+0.10=1\) and \(0.50+0.20+0.30=1\).

Why the Normalization Checks Work

Conditional rows and columns sum to one because their denominators are exactly the sums of the joint entries being divided. This is a useful verification, not just a convenient pattern to memorize.

Theorem: For a fixed \(j\) with \(P(Y=y_j)>0\), the values \(P(X=x_i\mid Y=y_j)\), \(i=1,\ldots,r\), form a pmf. For a fixed \(i\) with \(P(X=x_i)>0\), the values \(P(Y=y_j\mid X=x_i)\), \(j=1,\ldots,s\), form a pmf.

Proof. Each conditional probability is nonnegative because each joint entry is nonnegative and the denominator is positive. For the row conditional, summing over all values of \(X\) gives

$$ \sum_{i=1}^r P(X=x_i\mid Y=y_j) =\sum_{i=1}^r \frac{p_{ij}}{P(Y=y_j)} =\frac{\sum_{i=1}^r p_{ij}}{P(Y=y_j)} =\frac{P(Y=y_j)}{P(Y=y_j)} =1. $$

For the column conditional, summing over all values of \(Y\) gives

$$ \sum_{j=1}^s P(Y=y_j\mid X=x_i) =\sum_{j=1}^s \frac{p_{ij}}{P(X=x_i)} =\frac{\sum_{j=1}^s p_{ij}}{P(X=x_i)} =\frac{P(X=x_i)}{P(X=x_i)} =1. $$

Nonnegativity and a total of \(1\) establish the pmf property in each case. If a row or column total is zero, the corresponding conditional probabilities are not defined, so that case is excluded. \(\square\)

The same formulas can be rearranged to recover a joint entry from a conditional probability and its marginal probability. This provides a second way to check a table or to build one from conditional information.

Theorem: If \(P(Y=y_j)>0\), then \(P(X=x_i,Y=y_j)=P(X=x_i\mid Y=y_j)P(Y=y_j)\). If \(P(X=x_i)>0\), then \(P(X=x_i,Y=y_j)=P(Y=y_j\mid X=x_i)P(X=x_i)\).

Proof. By the definition of conditional probability, when \(P(Y=y_j)>0\),

$$ P(X=x_i\mid Y=y_j) =\frac{P(X=x_i,Y=y_j)}{P(Y=y_j)}. $$

Multiplying both sides by \(P(Y=y_j)\) gives the first identity. The definition with \(X=x_i\) as the conditioning event gives

$$ P(Y=y_j\mid X=x_i) =\frac{P(X=x_i,Y=y_j)}{P(X=x_i)}, $$

and multiplication by \(P(X=x_i)\) gives the second identity. \(\square\)

Worked Example: Reconstructing a Joint Table

Suppose \(P(Y=a)=0.20\), \(P(Y=b)=0.50\), and \(P(Y=c)=0.30\). The conditional pmfs of \(X\) given each value of \(Y\) are

Condition\(P(X=0\mid Y)\)\(P(X=1\mid Y)\)Row check
\(Y=a\)0.800.201.00
\(Y=b\)0.300.701.00
\(Y=c\)0.600.401.00

Multiply each conditional entry by its row marginal. For example, \(P(X=0,Y=a)=0.80(0.20)=0.16\) and \(P(X=1,Y=a)=0.20(0.20)=0.04\). Repeating this for the other rows gives the joint table:

\(X=0\)\(X=1\)Row total
\(Y=a\)0.160.040.20
\(Y=b\)0.150.350.50
\(Y=c\)0.180.120.30
Column total0.490.511.00

The row totals recover the supplied marginal distribution of \(Y\). The column totals give the implied marginal distribution of \(X\): \(P(X=0)=0.16+0.15+0.18=0.49\), and \(P(X=1)=0.04+0.35+0.12=0.51\). The entries are nonnegative, and the grand total is \(0.49+0.51=1\), so this is a valid joint table.

Zero Marginals and Careful Interpretation

A marginal total of zero means every joint entry in that row or column is zero, since entries are nonnegative. It does not make the conditional probabilities in that row or column equal to zero: those conditionals are undefined, because their denominator is zero. A conditional distribution must be normalized over an event that can occur with positive probability.

Worked Example: A Zero-Probability Conditioning Value

Consider this joint table.

\(X=0\)\(X=1\)Row total
\(Y=a\)0.200.300.50
\(Y=b\)0.100.400.50
\(Y=c\)000
Column total0.300.701.00

For \(Y=a\), divide its row by \(0.50\): \(P(X=0\mid Y=a)=0.20/0.50=0.40\) and \(P(X=1\mid Y=a)=0.30/0.50=0.60\). For \(Y=b\), the corresponding values are \(0.10/0.50=0.20\) and \(0.40/0.50=0.80\). But the row for \(Y=c\) has total zero, so \(P(X=0\mid Y=c)\) and \(P(X=1\mid Y=c)\) are not defined by conditional probability; the attempted ratios would have denominator zero.

The column conditionals are defined because both column totals are positive. Given \(X=0\), the probabilities for \(Y=a,b,c\) are \(0.20/0.30=2/3\), \(0.10/0.30=1/3\), and \(0/0.30=0\), which sum to \(1\). Given \(X=1\), they are \(0.30/0.70=3/7\), \(0.40/0.70=4/7\), and \(0/0.70=0\), also summing to \(1\).

Common Mistake: Normalizing in the Wrong Direction

A frequent error is to normalize by the marginal of the variable whose conditional distribution is being reported, rather than the variable after the conditioning bar. For example, \(P(X=x_i\mid Y=y_j)\) requires division by \(P(Y=y_j)\), not by \(P(X=x_i)\). In the first worked example, \(P(X=0\mid Y=a)=0.15/0.40=0.375\). Dividing \(0.15\) by the \(X=0\) column total \(0.50\) instead gives \(P(Y=a\mid X=0)=0.30\), a different conditional probability answering a different question.

A useful check is to say the conditioning statement in words before calculating: “given \(Y=a\)” fixes the row, so use that row total; “given \(X=0\)” fixes the column, so use that column total. Then check that the probabilities for the possible values of the other variable sum to \(1\). This check can catch a wrong denominator or arithmetic error, but a row or column summing to \(1\) alone does not verify that the original joint table is valid. Also check that all joint entries are nonnegative and that the grand total is \(1\).

Key takeaway: With \(Y\) in rows and \(X\) in columns, condition on \(Y\) by normalizing a row, and condition on \(X\) by normalizing a column. Use only positive marginal totals as denominators, and check both the conditional sums and the joint grand total.

Check Your Understanding

Use the table conventions from this tutorial: rows index \(Y\), and columns index \(X\).

  1. In a joint table, what total is the denominator when calculating \(P(X=x_i\mid Y=y_j)\)? What total is used for \(P(Y=y_j\mid X=x_i)\)?
  2. A row of joint probabilities is \(0.12, 0.18\), with row total \(0.30\). Calculate the two conditional probabilities for \(X\) given that row's value of \(Y\), and verify their sum.
  3. Why is a conditional pmf undefined for a row whose marginal total is zero, rather than a row of conditional probabilities all equal to zero?
  4. If \(P(Y=b)=0.4\), \(P(X=0\mid Y=b)=0.25\), and \(P(X=1\mid Y=b)=0.75\), calculate the two joint probabilities in the \(Y=b\) row and check its total.
  5. What checks should be made on a proposed joint probability table before using it to calculate conditional pmfs?