Statistics & Probability · Grade 12 and undergraduate

Joint Distributions, Covariance and Correlation

Quick answer

A joint distribution gives P(X = x, Y = y) for every pair of values. Adding across a row or down a column gives the marginal distributions of X and Y. The covariance Cov(X, Y) = E[XY] − E[X]E[Y] measures whether the two tend to be large together; dividing by both standard deviations gives the correlation, between −1 and 1. Independent variables have covariance 0, and in general Var(X + Y) = Var(X) + Var(Y) + 2Cov(X, Y).

What you'll learn

  • Find marginal and conditional probabilities from a joint table
  • Decide whether two random variables are independent
  • Compute covariance and correlation
  • Find the variance of a sum of dependent variables

A joint table

Two random variables XX and YY have this joint distribution. Each cell is P(X=x,Y=y)P(X = x, Y = y), and the margins hold the row and column sums.

Y=0Y = 0Y=1Y = 1Y=2Y = 2P(X=x)P(X = x)
X=0X = 00.10.20.10.4
X=1X = 10.20.10.30.6
P(Y=y)P(Y = y)0.30.30.41

The covariance and correlation are

Cov⁡(X,Y)=E[XY]−E[X] E[Y]ρ=Cov⁡(X,Y)σX σY\operatorname{Cov}(X, Y) = E[XY] - E[X]\,E[Y] \qquad \rho = \frac{\operatorname{Cov}(X, Y)}{\sigma_X\,\sigma_Y}

and for any XX and YY, Var⁡(X+Y)=Var⁡(X)+Var⁡(Y)+2Cov⁡(X,Y)\operatorname{Var}(X + Y) = \operatorname{Var}(X) + \operatorname{Var}(Y) + 2\operatorname{Cov}(X, Y).

Why covariance measures moving together

The definition is Cov⁡(X,Y)=E[(X−μX)(Y−μY)]\operatorname{Cov}(X, Y) = E[(X - \mu_X)(Y - \mu_Y)]. When XX is above its mean at the same times YY is above its mean, the product of the two deviations is positive, and the average is positive. Opposite movements give negative products, so the sign of the covariance tells the direction of the relationship. Expanding the product gives the shortcut E[XY]−E[X]E[Y]E[XY] - E[X]E[Y]. If XX and YY are independent, E[XY]=E[X]E[Y]E[XY] = E[X]E[Y] and the covariance is 00.

Worked examples

Common mistakes

Practice problems

Use the joint table above.

  1. Find P(X=1,Y=2)P(X = 1, Y = 2).

    Answer

    0.30.3

    Full solution

    Read the cell in row X=1X = 1, column Y=2Y = 2.

  2. Find P(Y=2)P(Y = 2).

    Answer

    0.40.4

    Full solution

    0.1+0.30.1 + 0.3.

  3. Find P(X=1∣Y=2)P(X = 1 \mid Y = 2).

    Answer

    0.750.75

    Full solution

    0.30.4\tfrac{0.3}{0.4}.

  4. Find E[XY]E[XY].

    Answer

    0.70.7

    Full solution

    1⋅1⋅0.1+1⋅2⋅0.31 \cdot 1 \cdot 0.1 + 1 \cdot 2 \cdot 0.3.

  5. Find Cov⁡(X,Y)\operatorname{Cov}(X, Y).

    Answer

    0.040.04

    Full solution

    0.7−0.6⋅1.10.7 - 0.6 \cdot 1.1.

  6. Find Var⁡(X+Y)\operatorname{Var}(X + Y).

    Answer

    1.011.01

    Full solution

    0.24+0.69+0.080.24 + 0.69 + 0.08.

  7. Are XX and YY independent?

    Answer

    No

    Full solution

    P(X=0,Y=0)=0.1≠0.4⋅0.3P(X = 0, Y = 0) = 0.1 \ne 0.4 \cdot 0.3.

  8. A student writes Cov⁡(3X,Y)=3+Cov⁡(X,Y)\operatorname{Cov}(3X, Y) = 3 + \operatorname{Cov}(X, Y). Find Cov⁡(3X,Y)\operatorname{Cov}(3X, Y).

    Answer

    0.120.12

    Full solution

    Constants factor out: 3Cov⁡(X,Y)=3⋅0.043\operatorname{Cov}(X, Y) = 3 \cdot 0.04.

Frequently asked questions

What is a marginal distribution?

The distribution of one variable alone, found by adding the joint probabilities over all values of the other.

How do I compute covariance?

Cov(X, Y) = E[XY] − E[X]E[Y], where E[XY] adds xy · P(X = x, Y = y) over every cell.

Does zero covariance mean independence?

No. Independence gives covariance 0, but covariance 0 can happen for dependent variables.

What is Var(X + Y) when X and Y are dependent?

Var(X) + Var(Y) + 2Cov(X, Y).

What to learn next