Skip to content

Joint distributions and covariance

6 min read

Short answer

A joint distribution gives P(X=x, Y=y)P(X=x,\ Y=y) for every pair of values. Summing across a row or column gives the marginals. The covariance measures whether the two variables move together: Cov⁡(X,Y)=E[XY]−E[X] E[Y].\operatorname{Cov}(X,Y)=E[XY]-E[X]\,E[Y]. Positive means they tend to be high together; zero is consistent with independence; negative means one tends to be high when the other is low.

Bar chart(0,0)(0,1)(1,0)(1,1)Joint probabilities P(X = x, Y = y) in the example below
Most of the probability sits on the matching pairs (0,0) and (1,1), so X and Y tend to agree: positive covariance.

From the table to the answers

Marginal of XX: add the probabilities across yy. Expectations: E[X]=∑xP(X=x)E[X]=\sum xP(X=x) and E[XY]=∑xy P(X=x,Y=y)E[XY]=\sum xy\,P(X=x,Y=y). If XX and YY are independent, every joint probability equals the product of the marginals and Cov⁡(X,Y)=0\operatorname{Cov}(X,Y)=0.

Zero covariance is not the same as independence

Independence implies zero covariance, but not the other way around. Covariance only detects linear association. For example, if XX is symmetric around 0 and Y=X2Y=X^2, then Cov⁡(X,Y)=0\operatorname{Cov}(X,Y)=0 although YY is completely determined by XX.

Worked example

X,Y∈{0,1}X,Y\in\{0,1\} with P(0,0)=0.4P(0,0)=0.4, P(0,1)=0.1P(0,1)=0.1, P(1,0)=0.1P(1,0)=0.1, P(1,1)=0.4P(1,1)=0.4. Find the marginals and Cov⁡(X,Y)\operatorname{Cov}(X,Y).

Marginals: P(X=1)=0.1+0.4=0.5P(X=1)=0.1+0.4=0.5, and similarly P(Y=1)=0.5P(Y=1)=0.5.

E[X]=E[Y]=0.5E[X]=E[Y]=0.5. The only pair with xy≠0xy\ne0 is (1,1)(1,1), so E[XY]=0.4E[XY]=0.4. Cov⁡(X,Y)=0.4−0.5⋅0.5=0.15>0.\operatorname{Cov}(X,Y)=0.4-0.5\cdot0.5=0.15>0. They tend to agree. (If the joint were 0.250.25 in every cell, E[XY]=0.25E[XY]=0.25 and the covariance would be 00.)

Try it yourself

If all four cells of the 2×2 table above equal 0.25, are XX and YY independent?

Show the answer

Yes. Each marginal is 0.5 and every cell is 0.25=0.5×0.50.25=0.5\times0.5, so the joint always factors. The covariance is 0.

Keep going with practice

Joint distributions extend Vidi's probability lessons from one variable to two.