Independent Random Variables

Two random variables X and Y are independent when knowing the value of one tells you nothing about the other. In symbols, the joint distribution factors into the marginals: p(x, y) = p_X(x)p_Y(y) for every x and y, or f(x, y) = f_X(x)f_Y(y) for densities. To test independent random variables, find the marginals and check whether their product equals the joint.

Before this lesson: Marginal and Conditional Distributions and Independent Events

What independence means for random variables

Two events A and B are independent when P(A and B) = P(A)P(B). Random variables carry this idea to every event at once: X and Y are independent when every event about X is independent of every event about Y.

In terms of distributions, this means the conditional distribution of Y given X = x is the same for every x, and equals the marginal of Y. Learning X does not shift, stretch or cut off the distribution of Y.

The test that is easiest to use is factoring. If the joint PMF or density is the product of the two marginals everywhere, the variables are independent. If it fails at even one point (for discrete variables) or on a region of positive area (for continuous ones), they are dependent.

Independent random variables: the rule

X and Y are independent exactly when

P(X \in A,\ Y \in B) = P(X \in A)\,P(Y \in B) \quad \text{for all sets } A \text{ and } B

For discrete and continuous variables this is the same as

p(x, y) = p_X(x)\,p_Y(y) \quad \text{or} \quad f(x, y) = f_X(x)\,f_Y(y) \quad \text{for all } x, y

Factorization shortcut: if the joint density can be written as f(x, y) = g(x)h(y) and the region where it is positive is a rectangle (a product set such as [a, b] × [c, d] or [0, ∞) × [0, ∞)), then X and Y are independent. A triangle or a disk as the region means dependent, whatever the formula looks like.

Independence gives useful product rules:

E(XY) = E(X)\,E(Y), \qquad \operatorname{Var}(X + Y) = \operatorname{Var}(X) + \operatorname{Var}(Y)

Steps

  1. Find the region where the joint PMF or density is positive. If it is not a product set (a full grid of cells, or a rectangle), stop: X and Y are dependent.
  2. Find both marginals by adding or integrating.
  3. Multiply the marginals and compare with the joint at every cell, or as formulas.
  4. If they agree everywhere, X and Y are independent. One disagreement is enough to show they are dependent.

Independent random variables examples

Example 1: A dependent table (word problem)

In the marginal and conditional distributions lesson, X laptops and Y tablets sold in an hour had joint table p(0, 0) = 0.20, p(0, 1) = 0.10, p(1, 0) = 0.25, p(1, 1) = 0.15, p(2, 0) = 0.20, p(2, 1) = 0.10, with marginals p_X = 0.30, 0.40, 0.30 and p_Y = 0.65, 0.35. Are X and Y independent?

p_X(0)\,p_Y(0) = 0.30 \times 0.65 = 0.195

Multiply the marginals for the cell (0, 0).

p(0, 0) = 0.20 \ne 0.195

Compare with the joint cell.

Answer: No. One cell that does not factor is enough, so X and Y are dependent. Knowing the laptop count changes the chances for tablets (for example, P(Y = 0 | X = 0) = 2/3, but P(Y = 0) = 0.65).

Example 2: An independent table (word problem)

A factory checks one box from line A and one box from line B each hour. X is the number of defective items in the line A box and Y the number in the line B box. Find whether X and Y are independent.

y = 0y = 1y = 2Marginal of X
x = 00.400.240.160.80
x = 10.100.060.040.20
Marginal of Y0.500.300.201
0.80 \times 0.50 = 0.40,\quad 0.80 \times 0.30 = 0.24,\quad 0.80 \times 0.20 = 0.16

Row x = 0: each product matches its cell.

0.20 \times 0.50 = 0.10,\quad 0.20 \times 0.30 = 0.06,\quad 0.20 \times 0.20 = 0.04

Row x = 1: each product matches its cell.

Answer: All six cells equal the product of their marginals, so X and Y are independent. Defects on one line give no information about defects on the other.

Example 3: A density that factors on a square

X and Y have joint density f(x, y) = 6xy² on the unit square 0 ≤ x ≤ 1, 0 ≤ y ≤ 1. Show that X and Y are independent, and find P(X ≤ 1/2, Y ≤ 1/2).

f_X(x) = \int_0^1 6xy^2\,dy = 6x \cdot \dfrac{1}{3} = 2x

Integrate out y.

f_Y(y) = \int_0^1 6xy^2\,dx = 6y^2 \cdot \dfrac{1}{2} = 3y^2

Integrate out x.

f_X(x)\,f_Y(y) = 2x \cdot 3y^2 = 6xy^2 = f(x, y)

The product equals the joint on the whole square.

P\left(X \le \tfrac{1}{2}\right) = \int_0^{1/2} 2x\,dx = \dfrac{1}{4}

Use the marginal of X.

P\left(Y \le \tfrac{1}{2}\right) = \int_0^{1/2} 3y^2\,dy = \dfrac{1}{8}

Use the marginal of Y.

P\left(X \le \tfrac{1}{2}, Y \le \tfrac{1}{2}\right) = \dfrac{1}{4} \cdot \dfrac{1}{8} = \dfrac{1}{32}

Independence lets you multiply.

Answer: X and Y are independent, and the probability is 1/32. With independence, one double integral becomes two single integrals.

Example 4: A formula that factors on a triangle

X and Y have joint density f(x, y) = 8xy on the triangle 0 ≤ y ≤ x ≤ 1. The formula 8xy looks like a product. Are X and Y independent?

Two panels. Left: the unit square 0 ≤ x ≤ 1, 0 ≤ y ≤ 1, fully shaded, labeled f = 6xy², independent, because the region is a rectangle. Right: the triangle 0 ≤ y ≤ x ≤ 1, shaded below the line y = x, labeled f = 8xy, dependent. The point (0.5, 0.8) is marked with an open circle above the triangle, where the joint density is 0 but f_X(0.5) times f_Y(0.8) is 0.576.
A rectangle is needed for independence: on the triangle, the point (0.5, 0.8) has joint density 0 but a positive product of marginals.
f_X(x) = 4x^3,\quad f_Y(y) = 4y - 4y^3

Marginals from the previous lesson (each on [0, 1]).

f(0.5, 0.8) = 0

The point (0.5, 0.8) has y greater than x, so it is outside the triangle.

f_X(0.5)\,f_Y(0.8) = 4(0.5)^3 \cdot \big(4(0.8) - 4(0.8)^3\big)

Multiply the marginals at the same point.

f_X(0.5)\,f_Y(0.8) = 0.5 \times (3.2 - 2.048) = 0.5 \times 1.152 = 0.576

Evaluate.

0.576 \ne 0

The product does not equal the joint.

Answer: X and Y are dependent. The region is a triangle: once you know X = 0.5, Y cannot exceed 0.5. The product does not match on a whole region of positive area (every point above the line y = x), not just one point.

Example 5: Battery and charger lifetimes (word problem)

A phone’s battery lasts X years and its charger lasts Y years. X is exponential with rate 0.5 per year, Y is exponential with rate 0.25 per year, and the two fail independently. Find the probability that both last more than 2 years, and the probability that the battery fails first.

f(x, y) = 0.5e^{-0.5x} \cdot 0.25e^{-0.25y} = 0.125e^{-0.5x - 0.25y},\quad x, y \ge 0

Independence: the joint density is the product of the exponential densities.

P(X \gt 2) = e^{-0.5(2)} = e^{-1}

Exponential survival function.

P(Y \gt 2) = e^{-0.25(2)} = e^{-0.5}

Exponential survival function.

P(X \gt 2,\ Y \gt 2) = e^{-1} \cdot e^{-0.5} = e^{-1.5} \approx 0.2231

Multiply, then add the exponents (see exponent rules).

P(X \lt Y) = \int_0^\infty 0.5e^{-0.5x} \left(\int_x^\infty 0.25e^{-0.25y}\,dy\right) dx

For each x, y runs from x to ∞.

\int_x^\infty 0.25e^{-0.25y}\,dy = e^{-0.25x}

Inner integral (see improper integrals).

P(X \lt Y) = \int_0^\infty 0.5e^{-0.75x}\,dx = \dfrac{0.5}{0.75} = \dfrac{2}{3}

Combine exponents and integrate.

Answer: P(both last more than 2 years) = e^(−1.5) ≈ 0.223, and the battery fails first with probability 2/3. Without independence, neither answer could be found from the two marginals alone.

Common mistakes

MistakeExample of the errorFix
Checking only one cellFinding p(0, 0) = p_X(0)p_Y(0) and stoppingIndependence needs every cell to factor. Dependence needs only one that fails.
Ignoring the regionSaying 8xy = (8x)(y), so X and Y are independent on a triangleThe region must be a rectangle (product set) too.
Treating zero correlation as independenceConcluding independence from E(XY) = E(X)E(Y)Independence implies that equation, but the equation does not imply independence.
Confusing independent with disjointSaying events about X and Y are independent because they can’t both happenEvents that can’t both happen are dependent (unless one has probability 0).
Multiplying without checkingP(X \le \tfrac{1}{2}, Y \le \tfrac{1}{2}) = P(X \le \tfrac{1}{2})P(Y \le \tfrac{1}{2}) in Example 4Multiply only after showing independence; otherwise integrate the joint density.

Related ideas

Sums of independent random variables

For independent X and Y, variances add: Var(X + Y) = Var(X) + Var(Y). This is the rule behind combining random variables in statistics. Practice problem 10 uses it.

Independent and identically distributed

A random sample is a list of independent random variables with the same distribution, called i.i.d. The central limit theorem and the law of large numbers are statements about i.i.d. variables.

Measuring dependence

When X and Y are dependent, covariance and correlation measure how strongly they move together in a straight-line way. That is the next lesson, Covariance.

Practice problems

  1. A joint table has p(0, 0) = 0.18, p(0, 1) = 0.42, p(1, 0) = 0.12, p(1, 1) = 0.28. Are X and Y independent?
  2. A joint table has p(0, 0) = 0.10, p(0, 1) = 0.30, p(1, 0) = 0.30, p(1, 1) = 0.30. Are X and Y independent?
  3. p(x, y) = (x + y)/21 for x = 1, 2 and y = 1, 2, 3. Are X and Y independent?
  4. p(x, y) = xy/9 for x = 1, 2 and y = 1, 2. Are X and Y independent?
  5. f(x, y) = 4xy on the unit square. Are X and Y independent?
  6. f(x, y) = x + y on the unit square. Are X and Y independent?
  7. f(x, y) = 6e^(−2x−3y) for x ≥ 0 and y ≥ 0. Are X and Y independent? Find P(X > 1, Y > 1).
  8. f(x, y) = 2 on the triangle 0 ≤ x ≤ y ≤ 1. Are X and Y independent?
  9. X and Y are independent and each uniform on [0, 1]. Find P(X ≤ 0.6 and Y ≤ 0.6), the probability that the larger of the two is at most 0.6.
  10. X and Y are independent with E(X) = 3, E(Y) = 5, Var(X) = 2 and Var(Y) = 4. Find E(XY), Var(X + Y) and Var(X − Y).
Show answers

1.

p_X(0) = 0.18 + 0.42 = 0.60,\quad p_X(1) = 0.40

Row totals.

p_Y(0) = 0.18 + 0.12 = 0.30,\quad p_Y(1) = 0.70

Column totals.

0.6 \times 0.3 = 0.18,\ 0.6 \times 0.7 = 0.42,\ 0.4 \times 0.3 = 0.12,\ 0.4 \times 0.7 = 0.28

Every product matches its cell.

Answer: independent

2.

p_X(0) = 0.40,\quad p_Y(0) = 0.10 + 0.30 = 0.40

Row and column totals.

p_X(0)\,p_Y(0) = 0.16 \ne 0.10 = p(0, 0)

One cell fails.

Answer: dependent

3.

p_X(1)\,p_Y(1) = \dfrac{3}{7} \cdot \dfrac{5}{21} = \dfrac{5}{49}

Marginals from the previous lesson.

p(1, 1) = \dfrac{2}{21} \ne \dfrac{5}{49}

Compare: 2/21 = 14/147 and 5/49 = 15/147.

Answer: dependent

4.

p_X(x) = \dfrac{x}{9}(1 + 2) = \dfrac{x}{3},\quad p_Y(y) = \dfrac{y}{3}

Add over the other variable.

p_X(x)\,p_Y(y) = \dfrac{xy}{9} = p(x, y)

Matches for all four cells.

Answer: independent

5.

f_X(x)\,f_Y(y) = 2x \cdot 2y = 4xy

Marginals 2x and 2y; the region is a square.

Answer: independent

6.

f_X(x) = x + \tfrac{1}{2},\quad f_Y(y) = y + \tfrac{1}{2}

Integrate out the other variable.

f_X(0)\,f_Y(0) = \tfrac{1}{4} \ne 0 = f(0, 0)

The product fails near the corner (0, 0), on a region of positive area.

Answer: dependent

7.

f(x, y) = 2e^{-2x} \cdot 3e^{-3y}

Factors, and the region [0, ∞) × [0, ∞) is a product set.

P(X \gt 1,\ Y \gt 1) = e^{-2} \cdot e^{-3} = e^{-5} \approx 0.00674

Multiply the survival probabilities.

Answer: independent; about 0.00674

8.

f(0.8, 0.2) = 0

The point has x greater than y, outside the triangle.

f_X(0.8)\,f_Y(0.2) = 2(1 - 0.8) \cdot 2(0.2) = 0.4 \cdot 0.4 = 0.16

Marginals f_X(x) = 2(1 − x) and f_Y(y) = 2y.

Answer: dependent (the region is a triangle)

9.

P(X \le 0.6,\ Y \le 0.6) = 0.6 \times 0.6 = 0.36

Multiply, using independence and P(X ≤ 0.6) = 0.6 for a uniform distribution.

Answer: 0.36

10.

E(XY) = E(X)E(Y) = 3 \times 5 = 15

Product rule for independent variables.

\operatorname{Var}(X + Y) = 2 + 4 = 6

Variances add.

\operatorname{Var}(X - Y) = 2 + (-1)^2(4) = 6

Variances still add, since Var(−Y) = Var(Y).

Answer: 15, 6 and 6

Independent random variables FAQ

How do you know if two random variables are independent?

Find the marginals and check whether their product equals the joint PMF or density everywhere. For densities, also check that the region where the density is positive is a rectangle.

Can X and Y be independent if the region is a triangle?

No. On a triangle, the value of X limits the possible values of Y, so the joint density is 0 at points where the product of the marginals is positive.

Does zero correlation mean the variables are independent?

No. Independent variables always have zero correlation, but dependent variables can also have zero correlation. For example, if X is uniform on [−1, 1] and Y = X², then Y depends completely on X, yet E(XY) = E(X)E(Y) = 0.

What is the difference between independent events and independent random variables?

Independent events are two single events with P(A and B) = P(A)P(B). Independent random variables satisfy that rule for every pair of events, one about X and one about Y.

Summary

  • X and Y are independent when the joint PMF or density equals the product of the marginals everywhere.
  • Shortcut: f(x, y) = g(x)h(y) on a rectangle means independent.
  • A non-rectangular region (such as a triangle) means dependent.
  • One failing cell proves dependence; independence needs all cells to factor.
  • Independence gives E(XY) = E(X)E(Y) and Var(X + Y) = Var(X) + Var(Y).

Previous lesson: Marginal and Conditional Distributions

Next lesson: Covariance

Back to the Probability Theory Index