Tutorials › Statistical Theory I - Probability and Distribution Theory › Conditional Independence and Its Factorization

Conditional Distribution Theory · Tutorial 265 of 994

Conditional Independence and Its Factorization

Learn to recognize conditional independence from conditional laws, probability masses, and densities—and to distinguish it from ordinary independence.

Intermediate 10 min read

What You'll Learn

  • Define conditional independence by factorization of conditional joint laws.
  • Check the discrete criterion using conditional probability masses.
  • Derive the density factorization criterion and identify where it applies.
  • Work through examples where conditional and marginal independence differ.
  • Avoid treating a conditional factorization as a marginal one.

Why Conditional Independence Needs Its Own Definition

Knowing a third variable can change the relationship between two others. For example, two outcomes may be independent once a group label is known, even though they are associated when the groups are combined. Or two outcomes may be independent overall but dependent within each level of a conditioning variable. Conditional independence describes the relationship after the information in that variable has been taken into account.

The central test is whether the conditional joint law factors into the two conditional marginal laws. This formulation applies to both discrete probability masses and continuous densities, but the factorization must be checked under the conditional law—not merely under the unconditional distribution.

Definition Through Conditional Laws

Let \(X\) and \(Y\) be real-valued random variables, and let \(Z\) be a random element taking values in a standard Borel space. Conditional distributions of \((X,Y)\), \(X\), and \(Y\) given \(Z=z\) can then be represented by probability kernels. Write \(K_{XY}(z;\cdot)\) for the conditional law of \((X,Y)\) given \(Z=z\), and \(K_X(z;\cdot)\) and \(K_Y(z;\cdot)\) for the corresponding marginal conditional laws.

Definition: \(X\) and \(Y\) are conditionally independent given \(Z\), written \(X\perp Y\mid Z\), if for \(P_Z\)-almost every \(z\), the conditional joint law is the product of its conditional marginal laws: $$ K_{XY}(z;A\times B)=K_X(z;A)K_Y(z;B) $$ for all Borel sets \(A,B\subseteq\mathbb{R}\). Equivalently, for every such \(A,B\), $$ P(X\in A,Y\in B\mid Z)=P(X\in A\mid Z)P(Y\in B\mid Z) \quad\text{almost surely.} $$

“Almost every” is with respect to the distribution of \(Z\): the factorization is required for conditioning values that occur in the probabilistic sense, not for values outside the support or for exceptional values of probability zero. The conditional probabilities in the second display are random variables determined by \(Z\). The definition says their product gives the conditional probability of the joint event.

When \(Z\) is discrete, this definition can be checked separately at each value \(z\) with \(P(Z=z)>0\). When densities exist, it becomes a factorization of conditional densities, as derived below.

The Discrete Factorization Criterion

Suppose \(X,Y,Z\) are countable-valued random variables. For any \(z\) with \(P(Z=z)>0\), define the conditional probability masses \(p_{xy\mid z}=P(X=x,Y=y\mid Z=z)\), \(p_{x\mid z}=P(X=x\mid Z=z)\), and \(p_{y\mid z}=P(Y=y\mid Z=z)\).

Theorem: For countable-valued \(X,Y,Z\), \(X\perp Y\mid Z\) if and only if, for every \(z\) with \(P(Z=z)>0\) and every \(x,y\), $$ p_{xy\mid z}=p_{x\mid z}p_{y\mid z}. $$

Proof. If \(X\perp Y\mid Z\), apply the definition to the singleton sets \(A=\{x\}\) and \(B=\{y\}\). This gives the stated equality for each \(x,y\) at each positive-probability value \(z\).

Conversely, suppose the equality holds for every \(x,y\) at a fixed \(z\) with positive probability. For any subsets \(A\) and \(B\) of the respective countable state spaces, countable additivity gives $$ \begin{aligned} P(X\in A,Y\in B\mid Z=z) &=\sum_{x\in A}\sum_{y\in B}p_{xy\mid z}\\ &=\sum_{x\in A}\sum_{y\in B}p_{x\mid z}p_{y\mid z}\\ &=\left(\sum_{x\in A}p_{x\mid z}\right) \left(\sum_{y\in B}p_{y\mid z}\right)\\ &=P(X\in A\mid Z=z)P(Y\in B\mid Z=z). \end{aligned} $$ The sums contain nonnegative terms, so the factorization of the double sum is valid, including for infinite countable state spaces. This is exactly the conditional-law definition. \(\square\)

Worked Example: Independent Within Groups, Associated Overall

Let \(Z\) be Bernoulli with \(P(Z=0)=P(Z=1)=1/2\). Given \(Z=z\), let \(X\) and \(Y\) be independent Bernoulli variables, each with success probability \(p_z\), where \(p_0=0.1\) and \(p_1=0.9\). Check conditional independence and compare it with marginal independence.

For either value of \(z\), conditional independence is part of the specified model. For instance, $$ P(X=1,Y=1\mid Z=z)=p_z^2 =P(X=1\mid Z=z)P(Y=1\mid Z=z). $$ The same product rule holds for the other pairs of binary outcomes, so \(X\perp Y\mid Z\).

Unconditionally, each success probability is $$ P(X=1)=P(Y=1)=\tfrac12(0.1)+\tfrac12(0.9)=0.5. $$ But the joint success probability is $$ P(X=1,Y=1)=\tfrac12(0.1^2)+\tfrac12(0.9^2) =\tfrac12(0.01+0.81)=0.41. $$ If \(X\) and \(Y\) were marginally independent, this probability would be \(0.5\times0.5=0.25\), not \(0.41\). Thus they are conditionally independent given \(Z\) but not marginally independent.

The Density Factorization Criterion

Now suppose \((X,Y,Z)\) has a joint density \(f_{X,Y,Z}(x,y,z)\), and the relevant marginal densities exist. Integrating the joint density gives $$ f_Z(z)=\int_{\mathbb{R}}\int_{\mathbb{R}}f_{X,Y,Z}(x,y,z)\,dx\,dy, $$ $$ f_{X,Z}(x,z)=\int_{\mathbb{R}}f_{X,Y,Z}(x,y,z)\,dy, \qquad f_{Y,Z}(y,z)=\int_{\mathbb{R}}f_{X,Y,Z}(x,y,z)\,dx. $$ For almost every \(z\) with \(f_Z(z)>0\), conditional densities can be chosen as $$ f_{X,Y\mid Z}(x,y\mid z)=\frac{f_{X,Y,Z}(x,y,z)}{f_Z(z)},\quad f_{X\mid Z}(x\mid z)=\frac{f_{X,Z}(x,z)}{f_Z(z)},\quad f_{Y\mid Z}(y\mid z)=\frac{f_{Y,Z}(y,z)}{f_Z(z)}. $$ The ratios are not used where \(f_Z(z)=0\), since those conditioning values do not determine a conditional law through this density formula.

Theorem: Under the density assumptions above, \(X\perp Y\mid Z\) if and only if, for almost every \(z\) with \(f_Z(z)>0\), $$ f_{X,Y\mid Z}(x,y\mid z) =f_{X\mid Z}(x\mid z)f_{Y\mid Z}(y\mid z) $$ for almost every \((x,y)\). Equivalently, $$ f_{X,Y,Z}(x,y,z)f_Z(z) =f_{X,Z}(x,z)f_{Y,Z}(y,z) $$ for almost every \((x,y,z)\) with \(f_Z(z)>0\).

Proof. Fix a \(z\) with \(f_Z(z)>0\) for which the conditional density formulas hold. If the conditional joint density is the product of the two conditional marginal densities almost everywhere, integrating over \(A\times B\) gives $$ \begin{aligned} P(X\in A,Y\in B\mid Z=z) &=\int_A\int_B f_{X,Y\mid Z}(x,y\mid z)\,dy\,dx\\ &=\left(\int_A f_{X\mid Z}(x\mid z)\,dx\right) \left(\int_B f_{Y\mid Z}(y\mid z)\,dy\right)\\ &=P(X\in A\mid Z=z)P(Y\in B\mid Z=z). \end{aligned} $$ The separation of the integrals follows from the product form and Tonelli’s theorem, which applies to these nonnegative densities. Thus the conditional laws factor.

In the other direction, suppose the conditional laws factor. Their conditional joint distribution is then the product of the two conditional marginal distributions. Since each has a density, that product distribution has density \(f_{X\mid Z}(x\mid z)f_{Y\mid Z}(y\mid z)\). Densities of the same distribution agree almost everywhere, so this product equals \(f_{X,Y\mid Z}(x,y\mid z)\) almost everywhere. Finally, substituting the three ratio formulas gives $$ \frac{f_{X,Y,Z}(x,y,z)}{f_Z(z)} =\frac{f_{X,Z}(x,z)}{f_Z(z)} \frac{f_{Y,Z}(y,z)}{f_Z(z)}, $$ which, after multiplication by \(f_Z(z)^2\), is the stated joint-density identity. The reverse algebra recovers the conditional-density product whenever \(f_Z(z)>0\). \(\square\)

Worked Example: Conditional Independence With Normal Densities

Let \(Z\sim N(0,1)\). Given \(Z=z\), suppose \(X\) and \(Y\) are independent, with \(X\mid Z=z\sim N(z,1)\) and \(Y\mid Z=z\sim N(2z,4)\). Write the conditional densities and verify the factorization.

The conditional densities are $$ f_{X\mid Z}(x\mid z)=\frac{1}{\sqrt{2\pi}} \exp\!\left(-\frac{(x-z)^2}{2}\right), $$ $$ f_{Y\mid Z}(y\mid z)=\frac{1}{\sqrt{8\pi}} \exp\!\left(-\frac{(y-2z)^2}{8}\right). $$ The specified conditional joint density is their product: $$ f_{X,Y\mid Z}(x,y\mid z) =\frac{1}{4\pi} \exp\!\left(-\frac{(x-z)^2}{2}-\frac{(y-2z)^2}{8}\right). $$ Therefore the density criterion holds for every \(z\), and \(X\perp Y\mid Z\). The means depend on \(z\), but that does not prevent conditional independence: the criterion compares the joint law with the conditional marginals at the same \(z\).

Worked Example: Marginal Independence Does Not Ensure Conditional Independence

Let \(X\) and \(Y\) be independent Bernoulli variables, each with success probability \(1/2\), and set \(Z=X+Y\). Show that they are marginally independent but not conditionally independent given \(Z\).

Marginal independence is part of the construction, and, for example, \(P(X=1,Y=1)=1/4=P(X=1)P(Y=1)\). Now condition on \(Z=1\), an event with probability $$ P(Z=1)=P(X=0,Y=1)+P(X=1,Y=0)=\tfrac14+\tfrac14=\tfrac12. $$ The two possible pairs, \((0,1)\) and \((1,0)\), each have conditional probability \((1/4)/(1/2)=1/2\). Hence $$ P(X=1\mid Z=1)=P(Y=1\mid Z=1)=\tfrac12, \qquad P(X=1,Y=1\mid Z=1)=0. $$ The product of the conditional marginal probabilities is \(1/4\), not \(0\). The conditional factorization fails at \(Z=1\), so \(X\not\perp Y\mid Z\).

Common Mistakes and Why the Distinction Matters

  • Replacing conditional independence with marginal independence. A product rule given \(Z\) concerns conditional probabilities or densities. It does not, by itself, give a product rule after averaging over \(Z\), as the first example demonstrates.
  • Assuming marginal independence survives conditioning. Conditioning changes the distribution being examined. In the last example, \(X\) and \(Y\) are marginally independent, but knowing their sum links their possible values.
  • Using a density identity where the conditioning density is zero. The ratio formulas require \(f_Z(z)>0\). The criterion is an almost-everywhere statement and makes no claim about conditional densities at unsupported values.
  • Checking only one pair of outcomes or one event. Conditional independence requires factorization for all relevant events. In countable settings the singleton mass criterion checks all pairs; with densities, the full conditional density must factor almost everywhere.

The factorization criterion is useful because it translates a conceptual claim—no remaining conditional association—into a calculation with the joint and marginal conditional laws. It also keeps two questions separate: whether \(X\) and \(Y\) are independent overall, and whether they are independent after \(Z\) is known. Neither answer can generally be substituted for the other.

Check Your Understanding

Use the conditional-law definition and factorization criteria to answer these questions.

  1. For countable-valued \(X,Y,Z\), what equality of conditional probability masses characterizes \(X\perp Y\mid Z\)?
  2. In the density setting, why must a conditional-density factorization be stated only for almost every \(z\) with \(f_Z(z)>0\)?
  3. In the Bernoulli-mixture example, calculate \(P(X=1)\), \(P(Y=1)\), and \(P(X=1,Y=1)\). Which calculation rules out marginal independence?
  4. In the normal-density example, what is the conditional mean of each variable given \(Z=z\), and why do varying conditional means not invalidate the factorization?
  5. For independent fair Bernoulli \(X\) and \(Y\) with \(Z=X+Y\), compare \(P(X=1,Y=1\mid Z=1)\) with \(P(X=1\mid Z=1)P(Y=1\mid Z=1)\).