Tutorials › Stochastic Processes › Conditional Distributions in Discrete Models

Random Variables, Expectation and Conditional Expectation · Tutorial 14 of 994

Conditional Distributions in Discrete Models

Build and verify conditional mass functions from joint laws, then apply them to tables and finite sampling.

Intermediate 10 min read

What You'll Learn

  • Construct a conditional mass function from a joint mass function.
  • Check when conditioning on a value is well-defined.
  • Verify conditional probabilities sum to one.
  • Read conditional laws in either direction from a contingency table.
  • Derive conditional laws for draws without replacement.
  • Identify and correct denominator errors in conditioning.

From a Joint Mass Function to a Conditional Law

A joint mass function describes two discrete random variables together. A conditional mass function answers a more focused question: once one variable is known to equal a particular value, how is probability distributed across the possible values of the other? The essential operation is to restrict attention to the relevant row or column of the joint law and divide by its total mass.

Let \(X\) and \(Y\) be discrete random variables on a probability space \((\Omega,\mathcal{F},\mathbb{P})\), taking values in countable sets \(\mathcal{X}\) and \(\mathcal{Y}\). Their joint mass function is \(p_{X,Y}(x,y)=\mathbb{P}(X=x,Y=y)\), and their marginal mass functions are obtained by summing over the other variable. In particular, \(p_Y(y)=\sum_{x\in\mathcal{X}}p_{X,Y}(x,y)\).

Definition: If \(p_Y(y)>0\), the conditional mass function of \(X\) given \(Y=y\) is \(p_{X\mid Y}(x\mid y)=\mathbb{P}(X=x\mid Y=y)=\frac{p_{X,Y}(x,y)}{p_Y(y)}\), for \(x\in\mathcal{X}\). It is defined only for values \(y\) with positive marginal probability. The conditional mass function of \(Y\) given \(X=x\) is defined in the reverse direction when \(p_X(x)>0\).

The denominator is the probability of the conditioning event, not the probability of the particular joint outcome. Because the joint mass in the numerator is part of the total mass in the conditioning row or column, this division makes the conditional masses add to one.

Theorem (Conditional mass function from a joint law): Let \(X,Y\) be discrete and suppose \(p_Y(y)>0\). Then \(p_{X\mid Y}(x\mid y)=p_{X,Y}(x,y)/p_Y(y)\) is a probability mass function in \(x\): it is nonnegative, sums to one, and for every set \(C\subseteq\mathcal{X}\), \(\mathbb{P}(X\in C\mid Y=y)=\sum_{x\in C}p_{X\mid Y}(x\mid y)\).

Proof. Each joint mass \(p_{X,Y}(x,y)\) is nonnegative and \(p_Y(y)>0\), so the ratio is nonnegative. Summing over all \(x\) gives \(\sum_x p_{X\mid Y}(x\mid y)=\sum_x p_{X,Y}(x,y)/p_Y(y)=p_Y(y)/p_Y(y)=1\). For any \(C\subseteq\mathcal{X}\), the event \(\{X\in C,Y=y\}\) is the disjoint union of the events \(\{X=x,Y=y\}\) for \(x\in C\). Thus its probability is \(\sum_{x\in C}p_{X,Y}(x,y)\). Dividing this probability by \(\mathbb{P}(Y=y)=p_Y(y)\), as required by conditional probability on a positive-probability event, gives \(\mathbb{P}(X\in C\mid Y=y)=\sum_{x\in C}p_{X\mid Y}(x\mid y)\). \(\square\)

A useful consequence is that a conditional probability for a set is found by summing conditional masses over that set. For example, \(p_{X\mid Y}(x\mid y)\) gives the law of \(X\) after \(Y=y\) is known; it is not the joint probability of \((X,Y)=(x,y)\). Conversely, multiplying by the marginal recovers the joint mass: \(p_{X,Y}(x,y)=p_{X\mid Y}(x\mid y)p_Y(y)\) whenever \(p_Y(y)>0\).

Proposition (Grouping values): Suppose \(p_Y(y)>0\), and let \(g\) be a function on \(\mathcal{X}\). For any value \(u\), the conditional probability that \(g(X)=u\) is \(\mathbb{P}(g(X)=u\mid Y=y)=\sum_{x:g(x)=u}p_{X\mid Y}(x\mid y)\).

Proof. The event \(\{g(X)=u\}\) is the disjoint union of \(\{X=x\}\) over the values \(x\) satisfying \(g(x)=u\). Intersecting each event with \(\{Y=y\}\) preserves disjointness. Therefore \(\mathbb{P}(g(X)=u,Y=y)=\sum_{x:g(x)=u}p_{X,Y}(x,y)\). Since \(p_Y(y)>0\), divide both sides by \(p_Y(y)\). Each term on the right becomes \(p_{X\mid Y}(x\mid y)\), and the left is the stated conditional probability. \(\square\)

Reading Conditional Laws from a Joint Table

In a joint probability table, each entry is a joint mass. To find \(X\) given \(Y=y\), select the column for \(y\) and divide every entry in that column by its column total. To find \(Y\) given \(X=x\), use the row for \(x\) and divide by its row total. First check the joint masses sum to one, and then check each conditional distribution sums to one. A conditioning value with zero marginal mass cannot be used in the ratio.

Worked Example: Conditioning on a Column of a Joint Law

Suppose the joint mass function of \(X\in\{0,1,2\}\) and \(Y\in\{a,b\}\) is displayed below. Find the conditional mass function of \(X\) given \(Y=a\) and given \(Y=b\), and calculate \(\mathbb{P}(X\ge1\mid Y=b)\).

\(X\backslash Y\)\(a\)\(b\)Marginal \(p_X(x)\)
0\(\tfrac{1}{10}\)\(\tfrac{1}{5}\)\(\tfrac{3}{10}\)
1\(\tfrac{1}{5}\)\(\tfrac{1}{10}\)\(\tfrac{3}{10}\)
2\(\tfrac{1}{10}\)\(\tfrac{3}{10}\)\(\tfrac{2}{5}\)
Marginal \(p_Y(y)\)\(\tfrac{2}{5}\)\(\tfrac{3}{5}\)1

The \(a\)-column total is \(\tfrac{1}{10}+\tfrac{1}{5}+\tfrac{1}{10}=\tfrac{4}{10}=\tfrac{2}{5}\), and the \(b\)-column total is \(\tfrac{1}{5}+\tfrac{1}{10}+\tfrac{3}{10}=\tfrac{6}{10}=\tfrac{3}{5}\). The three row totals are \(\tfrac{1}{10}+\tfrac{1}{5}=\tfrac{3}{10}\), \(\tfrac{1}{5}+\tfrac{1}{10}=\tfrac{3}{10}\), and \(\tfrac{1}{10}+\tfrac{3}{10}=\tfrac{2}{5}\). The joint total is \(\tfrac{2}{5}+\tfrac{3}{5}=1\), so the entries form a probability law.

Since both column totals are positive, both requested conditional laws are defined. For \(Y=a\), divide the entries \(\tfrac{1}{10},\tfrac{1}{5},\tfrac{1}{10}\) by \(\tfrac{2}{5}\): the conditional masses at \(x=0,1,2\) are \(\tfrac{1}{4},\tfrac{1}{2},\tfrac{1}{4}\). Their sum is \(\tfrac{1}{4}+\tfrac{1}{2}+\tfrac{1}{4}=1\). For \(Y=b\), divide \(\tfrac{1}{5},\tfrac{1}{10},\tfrac{3}{10}\) by \(\tfrac{3}{5}\): the masses are \(\tfrac{1}{3},\tfrac{1}{6},\tfrac{1}{2}\). Their sum is \(\tfrac{1}{3}+\tfrac{1}{6}+\tfrac{1}{2}=\tfrac{2}{6}+\tfrac{1}{6}+\tfrac{3}{6}=1\).

The event \(X\ge1\) consists of \(X=1\) and \(X=2\). Therefore \(\mathbb{P}(X\ge1\mid Y=b)=\tfrac{1}{6}+\tfrac{1}{2}=\tfrac{2}{3}\). As a check directly from the joint law, the relevant joint mass is \(\tfrac{1}{10}+\tfrac{3}{10}=\tfrac{2}{5}\), and \((\tfrac{2}{5})/(\tfrac{3}{5})=\tfrac{2}{3}\), agreeing with the sum of the conditional masses.

Conditional Distributions from Counts and Sampling

A contingency table often records counts rather than probabilities. If each observation is treated as equally likely to be selected from the table, divide every count by the grand total to get the empirical joint mass function. Conditional probabilities then come from dividing a cell count by the total count in the conditioning row or column. The direction matters: conditioning on a group and conditioning on an outcome usually use different totals.

Worked Example: Conditional Laws in a Contingency Table

A study records a group label \(G\in\{A,B\}\) and an outcome \(R\in\{1,2,3\}\). The entries are numbers of observations. Find the outcome distribution conditional on group \(A\), and the group distribution conditional on outcome \(R=1\).

Group\(R=1\)\(R=2\)\(R=3\)Total
\(A\)18121040
\(B\)8161640
Total26282680

The row totals are \(18+12+10=40\) and \(8+16+16=40\). The column totals are \(18+8=26\), \(12+16=28\), and \(10+16=26\), giving grand total \(26+28+26=80\). The empirical joint masses are the displayed counts divided by \(80\); they sum to \(80/80=1\).

Within group \(A\), the total is 40, so the conditional probabilities of outcomes \(1,2,3\) are \(18/40=9/20\), \(12/40=3/10\), and \(10/40=1/4\). The normalization check is \(9/20+3/10+1/4=9/20+6/20+5/20=1\).

For the reverse conditioning, \(R=1\) has total count 26. Thus \(\mathbb{P}(G=A\mid R=1)=18/26=9/13\), while \(\mathbb{P}(G=B\mid R=1)=8/26=4/13\). These add to \(9/13+4/13=1\). Both conditioning events have positive counts, so both conditional distributions are defined.

Check by joint masses: the joint mass for \(G=A,R=1\) is \(18/80\), and the marginal mass for \(R=1\) is \(26/80\). Their ratio is \((18/80)/(26/80)=18/26=9/13\), as obtained from the table counts.

Sampling without replacement produces conditional laws by the same rule. The joint masses come from multiplying the probabilities of successive draws, updating the available composition after each draw. The conditional distribution can then be read from the joint table by dividing by the appropriate marginal.

Worked Example: Two Draws Without Replacement

An urn contains 3 red and 2 blue balls. Two balls are drawn in order without replacement. Let \(X=1\) if the first ball is red and \(X=0\) if it is blue; let \(Y\) be the total number of red balls drawn. Find the conditional distribution of \(Y\) given \(X=0\), and the conditional distribution of \(X\) given \(Y=1\).

The possible pairs \((X,Y)\) are \((0,0),(0,1),(1,1),(1,2)\). The probability of \((X,Y)=(0,0)\) is \((2/5)(1/4)=2/20=1/10\): the first draw is blue and then a blue ball is drawn from the remaining four. The probability of \((0,1)\) is \((2/5)(3/4)=6/20=3/10\). The probability of \((1,1)\) is \((3/5)(2/4)=6/20=3/10\), and that of \((1,2)\) is \((3/5)(2/4)=6/20=3/10\).

\(X\backslash Y\)012Marginal \(p_X(x)\)
0\(\tfrac{1}{10}\)\(\tfrac{3}{10}\)0\(\tfrac{2}{5}\)
10\(\tfrac{3}{10}\)\(\tfrac{3}{10}\)\(\tfrac{3}{5}\)
Marginal \(p_Y(y)\)\(\tfrac{1}{10}\)\(\tfrac{3}{5}\)\(\tfrac{3}{10}\)1

The joint masses sum to \(\tfrac{1}{10}+\tfrac{3}{10}+\tfrac{3}{10}+\tfrac{3}{10}=1\). The marginal for \(X=0\) is \(\tfrac{1}{10}+\tfrac{3}{10}=\tfrac{2}{5}\), which is positive. Given \(X=0\), the conditional masses for \(Y=0,1,2\) are \((\tfrac{1}{10})/(\tfrac{2}{5})=\tfrac{1}{4}\), \((\tfrac{3}{10})/(\tfrac{2}{5})=\tfrac{3}{4}\), and \(0/(\tfrac{2}{5})=0\). They sum to \(\tfrac{1}{4}+\tfrac{3}{4}+0=1\).

The marginal probability of \(Y=1\) is \(\tfrac{3}{10}+\tfrac{3}{10}=\tfrac{3}{5}>0\). Consequently, the conditional probabilities that \(X=0\) and \(X=1\) given \(Y=1\) are \((\tfrac{3}{10})/(\tfrac{3}{5})=\tfrac{1}{2}\) and \((\tfrac{3}{10})/(\tfrac{3}{5})=\tfrac{1}{2}\). Their sum is 1. Substitution back into the joint law checks both entries: \((\tfrac{1}{2})(\tfrac{3}{5})=\tfrac{3}{10}\) for each possible value of \(X\) when \(Y=1\).

Denominators, Zero-Mass Values, and a Common Error

A conditional mass function is a probability distribution only after normalization by the marginal mass of the conditioning value. A common mistake is to divide a joint cell by the grand total even though the question conditions on a row or column. In the contingency table above, the grand total is 80, but the event \(R=1\) has total 26. Thus \(18/80\) is the joint probability of \(G=A,R=1\), not \(\mathbb{P}(G=A\mid R=1)\). The correct calculation is \(18/26=9/13\), because the conditional probabilities over the possible groups must sum to one: \(18/26+8/26=1\). The incorrect values \(18/80\) and \(8/80\) sum to \(26/80\), not one.

If \(p_Y(y)=0\), then every joint mass \(p_{X,Y}(x,y)\) is zero, and the ratio defining \(p_{X\mid Y}(x\mid y)\) has zero denominator. There is no conditional mass function specified by this ratio at that value. Do not divide by zero or infer a conditional law from a zero-probability column. By contrast, a zero joint cell within a positive-mass column simply gives a zero conditional probability, as in the urn example.

The central checks are straightforward: verify the joint masses or counts are consistent, identify the conditioning value and its marginal total, divide every entry in that slice by the same total, and check the resulting conditional masses sum to one. Reversing the roles of \(X\) and \(Y\) changes the conditioning slice and its denominator.

Check Your Understanding

For each question, identify the conditioning marginal before calculating, and check that the resulting conditional probabilities sum to one.

  1. If \(p_{X,Y}(0,a)=\tfrac{1}{8}\), \(p_{X,Y}(1,a)=\tfrac{3}{8}\), and \(p_Y(a)=\tfrac{1}{2}\), find \(p_{X\mid Y}(0\mid a)\) and \(p_{X\mid Y}(1\mid a)\).
  2. In a contingency table, a column has counts 7 and 5 for two groups. What is the conditional probability of the first group given that column's outcome?
  3. Why is \(p_{X\mid Y}(x\mid y)\) not defined by the joint-mass ratio when \(p_Y(y)=0\)?
  4. For the urn example, find \(\mathbb{P}(Y=2\mid X=1)\) and verify the full conditional distribution of \(Y\) given \(X=1\).
  5. Explain how to compute \(\mathbb{P}(g(X)=u\mid Y=y)\) from \(p_{X\mid Y}(x\mid y)\) when \(p_Y(y)>0\).