Tutorials › Exam P - Probability › Conditional Laws as an Independence Test

Exam P · Conditional Distributions and Independence · Tutorial 748 of 915

Conditional Laws as an Independence Test

Use conditional distributions to test independence correctly, including the almost-everywhere qualification for continuous conditioning variables.

Intermediate 10 min read

What You'll Learn

  • State the conditional-law criterion for independence.
  • Compare conditional and marginal distributions in discrete models.
  • Derive conditional densities and conditional probabilities from a joint density.
  • Distinguish a genuine mismatch from a difference at a null conditioning value.
  • Use conditional distributions to verify independence in a continuous model.

Why Compare Conditional and Marginal Laws?

Independence means that learning the value of one random variable does not change the probability law of the other. Conditional distributions make that idea precise: if \(X\) and \(Y\) are independent, the distribution of \(X\) given \(Y\) should match the unconditional distribution of \(X\). Conversely, if those laws agree for the relevant conditioning values, that is a test for independence.

The qualification “relevant” matters. For a discrete \(Y\), conditioning on \(Y=y\) is meaningful when \(P(Y=y)>0\). For a continuous \(Y\), an exact value has probability zero, and conditional distributions are determined only up to changes on sets of \(Y\)-probability zero. A correct test must account for this distinction.

Definition: \(X\) and \(Y\) are independent if, for every pair of measurable sets \(A\) and \(B\), \(P(X\in A,Y\in B)=P(X\in A)P(Y\in B)\). Equivalently, the conditional law of \(X\) given \(Y=y\) equals the marginal law of \(X\) for \(P_Y\)-almost every \(y\). Here \(P_Y\)-almost every means that any exceptional set of conditioning values has probability zero under the distribution of \(Y\).

In terms of conditional distribution functions, the comparison is between \(F_{X\mid Y=y}(x)=P(X\le x\mid Y=y)\) and \(F_X(x)=P(X\le x)\). Equality of the conditional and marginal laws means equality of these distribution functions for every \(x\), apart from the allowed null set of conditioning values. Equivalently, it is enough to check equality at all rational \(x\) on a common set of conditioning values of probability one; the right-continuity of distribution functions then gives equality for all real \(x\).

The Criterion in Discrete and Continuous Models

For discrete variables, conditional probabilities are ratios of joint and marginal probabilities. If \(P(Y=y)>0\), then \(P(X=x\mid Y=y)=P(X=x,Y=y)/P(Y=y)\). Independence requires these conditional probabilities to equal \(P(X=x)\) for every \(x\) and every \(y\) with positive probability. Comparing only one value of \(x\) is not generally enough to establish independence: the entire conditional distribution must match.

For jointly continuous variables with joint density \(f_{X,Y}\), the conditional density is \(f_{X\mid Y}(x\mid y)=f_{X,Y}(x,y)/f_Y(y)\) where the ratio is defined. Independence requires this conditional density to equal \(f_X(x)\) for \(f_Y\)-almost every \(y\), and for almost every \(x\). Density equality is naturally an almost-everywhere statement because changing a density on a set of area zero does not change the distribution.

Theorem: Independence is equivalent to equality of the conditional and marginal laws of \(X\) for \(P_Y\)-almost every conditioning value. If \(Y\) is discrete, this means equality at every \(y\) with \(P(Y=y)>0\). If \(Y\) is continuous, equality is required for \(f_Y\)-almost every \(y\), not necessarily at every individual \(y\).

Why the Conditional-Law Test Works

The result follows directly from the definition of conditional probability, or its continuous-density counterpart. In the discrete case, the conditional probability is the joint probability divided by the marginal probability of the conditioning value. In the continuous case, the corresponding identity is the factorization of the joint density into a conditional density and the marginal density.

1
Independence implies equality.
If \(X\) and \(Y\) are independent, then for any set \(A\), \(P(X\in A,Y\in B)=P(X\in A)P(Y\in B)\). Dividing by \(P(Y\in B)>0\) gives \(P(X\in A\mid Y\in B)=P(X\in A)\). The corresponding conditional law given \(Y=y\) is therefore the marginal law for \(P_Y\)-almost every \(y\).
2
Equality implies independence.
If the conditional law of \(X\) given \(Y=y\) equals the marginal law for \(P_Y\)-almost every \(y\), then for any measurable sets \(A\) and \(B\), \(P(X\in A,Y\in B)=\int_B P(X\in A\mid Y=y)\,dP_Y(y)=\int_B P(X\in A)\,dP_Y(y)=P(X\in A)P(Y\in B)\). This is the definition of independence.

This argument also explains why a conditional law at a single continuous conditioning value cannot be treated in the same way as a positive-probability discrete value. Conditional distributions can be changed at an individual \(y\) with \(P(Y=y)=0\) without affecting the integral, and therefore without affecting the joint distribution.

Worked Example: Testing Independence From a Discrete Table

Let \(X\) take values 0 and 1, and let \(Y\) take values \(A\) and \(B\). The joint probabilities are \(P(X=1,Y=A)=0.24\), \(P(X=1,Y=B)=0.36\), \(P(X=0,Y=A)=0.16\), and \(P(X=0,Y=B)=0.24\). Determine whether \(X\) and \(Y\) are independent.

Method. First verify that the table is a probability distribution, then compare the conditional law of \(X\) at each positive-probability value of \(Y\) with the marginal law of \(X\). This avoids using conditional ratios before checking that the joint probabilities are valid.

The four entries sum to \(0.24+0.36+0.16+0.24=1.00\), so the table is normalized. The marginal probability of \(X=1\) is \(P(X=1)=0.24+0.36=0.60\), and \(P(X=0)=1-0.60=0.40\).

The marginal probabilities for \(Y\) are \(P(Y=A)=0.24+0.16=0.40\) and \(P(Y=B)=0.36+0.24=0.60\). Both are positive, so both conditioning values must be checked.

For \(Y=A\), \(P(X=1\mid Y=A)=0.24/0.40=0.60\), and \(P(X=0\mid Y=A)=0.16/0.40=0.40\). For \(Y=B\), \(P(X=1\mid Y=B)=0.36/0.60=0.60\), and \(P(X=0\mid Y=B)=0.24/0.60=0.40\). At both values of \(Y\), the conditional distribution of \(X\) equals its marginal distribution.

Conclusion and check. \(X\) and \(Y\) are independent. For instance, \(P(X=1)P(Y=A)=0.60(0.40)=0.24=P(X=1,Y=A)\); the other three products agree with the table by the same calculation. The conditional-law conclusion is consistent with joint-marginal factorization.

Worked Example: A Continuous Conditional Law That Changes With \(y\)

Suppose the joint density of \(X\) and \(Y\) is \(f_{X,Y}(x,y)=1+\tfrac12(2x-1)(2y-1)\) on \(0<x<1,\ 0<y<1\), and zero elsewhere. Determine whether \(X\) and \(Y\) are independent by comparing a conditional probability with its marginal counterpart.

Method. Find the marginal densities by integration, form the conditional density, and compare probabilities at the same threshold. A mismatch over a positive-probability set of conditioning values disproves independence.

First, the density is nonnegative: each factor \(2x-1\) and \(2y-1\) lies between \(-1\) and 1, so their product lies between \(-1\) and 1. Thus \(f_{X,Y}\) lies between \(0.5\) and \(1.5\). Its integral is 1 because the integral of \(2x-1\) from 0 to 1 is zero, so the product term integrates to zero.

For \(0<y<1\), integrate with respect to \(x\). The term involving \(2x-1\) integrates to zero, giving \(f_Y(y)=1\). Similarly, \(f_X(x)=1\) for \(0<x<1\). Thus both marginal distributions are uniform on \((0,1)\), and \(P(X\le 0.5)=0.5\).

Since \(f_Y(y)=1\) on the support, the conditional density is \(f_{X\mid Y}(x\mid y)=1+\tfrac12(2x-1)(2y-1)\). Integrating from 0 to 0.5 gives \(P(X\le 0.5\mid Y=y)=0.5-\tfrac18(2y-1)=0.625-0.25y\).

For example, at \(y=0.25\), this conditional probability is \(0.625-0.25(0.25)=0.5625\), which differs from the marginal probability \(0.5\). More importantly, the expression differs from \(0.5\) for every \(y\) in \((0,0.25)\), a set with positive probability under the uniform distribution of \(Y\).

Conclusion and check. The variables are dependent. The conditional probability is in the valid range: for \(0<y<1\), it lies between \(0.375\) and \(0.625\). The conclusion does not rest on a mismatch at just one exact conditioning value; the mismatch occurs on a whole interval of positive probability.

Worked Example: Verifying Independence With Conditional Densities

Suppose \(f_{X,Y}(x,y)=x\) for \(0<x<1,\ 0<y<2\), and zero elsewhere. Verify that this is a joint density, test independence using the conditional law of \(X\) given \(Y=y\), and find \(P(X>0.5\mid Y=1.5)\).

Method. Compute both marginals and the conditional density. Equality of the conditional and marginal densities provides the independence test and then supplies the requested conditional probability.

The integral of the joint density is \(\int_0^2\int_0^1 x\,dx\,dy=\int_0^2 \tfrac12\,dy=1\), so it is normalized. The marginal density of \(Y\) is \(f_Y(y)=\int_0^1 x\,dx=0.5\) for \(0<y<2\). The marginal density of \(X\) is \(f_X(x)=\int_0^2 x\,dy=2x\) for \(0<x<1\).

For any \(0<y<2\), the conditional density is \(f_{X\mid Y}(x\mid y)=x/0.5=2x\), for \(0<x<1\). This equals \(f_X(x)\) for every such \(y\), so \(X\) and \(Y\) are independent.

The requested probability is \(P(X>0.5\mid Y=1.5)=\int_{0.5}^1 2x\,dx=[x^2]_{0.5}^1=1-0.25=0.75\).

Conclusion and check. The conditional density integrates to \([x^2]_0^1=1\), and the probability \(0.75\) also equals the marginal probability \(P(X>0.5)\), as independence requires.

Common Mistakes and Exam Traps

  • Checking only one part of a discrete conditional law. Matching \(P(X=1\mid Y=y)\) with \(P(X=1)\) is enough when \(X\) is binary, because the probability at \(X=0\) is then its complement. For a variable with more than two possible values, check the full distribution, not just one outcome.
  • Ignoring normalization. Before calculating conditional probabilities from a table, verify that the joint probabilities sum to 1. If they do not, they are not a valid joint distribution as stated.
  • Using a single continuous conditioning value as decisive evidence. A conditional law may be altered at a \(Y\)-null value without changing the model. A mismatch that proves dependence must occur on a set of conditioning values with positive probability.
  • Checking equality only at one threshold. A mismatch at a threshold for a positive-probability set of conditioning values is enough to disprove independence. But proving independence requires equality of the entire conditional and marginal laws, not just one probability.
  • Confusing the conditional density with a probability. A density value such as \(f_{X\mid Y}(x\mid y)\) is not itself a probability. Integrate it over an interval to obtain a conditional probability.
Key takeaway: Test independence by comparing the entire conditional law of \(X\) given \(Y=y\) with the marginal law of \(X\). Check every positive-probability conditioning value when \(Y\) is discrete; when \(Y\) is continuous, the comparison is required almost everywhere with respect to the distribution of \(Y\).

Check Your Understanding

For each problem, use the conditional-law criterion and keep track of which conditioning values are relevant.

  1. Let \(X\in\{0,1\}\) and \(Y\in\{A,B\}\), with joint probabilities \(P(X=1,Y=A)=0.18\), \(P(X=1,Y=B)=0.27\), \(P(X=0,Y=A)=0.22\), and \(P(X=0,Y=B)=0.33\). Find \(P(X=1)\) and the conditional probabilities needed to decide independence. (Answer: \(P(X=1)=0.45\); \(P(X=1\mid Y=A)=0.45\) and \(P(X=1\mid Y=B)=0.45\), so \(X,Y\) are independent.)
  2. Let \(P(X=1,Y=A)=0.10\), \(P(X=1,Y=B)=0.40\), \(P(X=0,Y=A)=0.30\), and \(P(X=0,Y=B)=0.20\). Compare \(P(X=1\mid Y=A)\) with \(P(X=1)\). (Answer: \(P(X=1)=0.50\), while \(P(X=1\mid Y=A)=0.10/0.40=0.25\); the pair is dependent.)
  3. For the density \(f_{X,Y}(x,y)=1+\tfrac12(2x-1)(2y-1)\) on the unit square, find \(P(X\le0.5\mid Y=y)\) and state whether the pair is independent. (Answer: \(0.625-0.25y\); it differs from \(P(X\le0.5)=0.5\) on a set of \(y\)-values with positive probability, so the pair is dependent.)
  4. Suppose \(f_{X,Y}(x,y)=x\) on \(0<x<1,\ 0<y<2\). Find \(P(X>0.5\mid Y=1.5)\) and decide independence. (Answer: \(0.75\); \(f_{X\mid Y}(x\mid y)=2x=f_X(x)\), so the variables are independent.)
  5. Suppose \(X\) and \(Y\) are independent and \(Y\) is uniform on \((0,1)\). A version of the conditional law of \(X\) given \(Y=y\) is changed only at \(y=0.5\), where it is set to a different distribution. Does this change establish dependence? (Answer: No. \(P(Y=0.5)=0\), so changing a conditional-law version at that single null value does not alter the joint distribution or the almost-everywhere independence criterion.)
Clinical Biostats