Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Let XX be a random variable. In what follows, we will use some familiar shorthand:

  • μX=E(X)\mu_X = E(X), σX=SD(X)\sigma_X = SD(X)

Let DX=XμXD_X = X - \mu_X denote the deviation of XX from its mean. Then the variance of XX can be written as

Var(X)=σX2=E(DX2)Var(X) = \sigma_X^2 = E(D_X^2)
🎥 See More
Loading...

13.1.1Variance of a Sum

Now let XX and YY be two random variables on the same space, and let S=X+YS = X+Y. Then E(S)=μX+μYE(S) = \mu_X + \mu_Y, and the deviation of SS is the sum of the deviations of XX and YY:

DS = SμS = X+Y(μX+μY) = DX+DYD_S ~ = ~ S - \mu_S ~ = ~ X + Y - (\mu_X + \mu_Y) ~ = ~ D_X + D_Y

This gives us some insight into the variance of the sum SS.

Var(S)=E(DS2)=E[(DX+DY)2]=E(DX2)+E(DY2)+2E(DXDY)=Var(X)+Var(Y)+2E(DXDY)\begin{align*} Var(S) &= E(D_S^2) \\ &= E[(D_X + D_Y)^2] \\ &= E(D_X^2) + E(D_Y^2) + 2E(D_XD_Y) \\ &= Var(X) + Var(Y) + 2E(D_XD_Y) \end{align*}

The first thing to note is that while the expectation of a sum is the sum of the expectations, the calculation above shows that the variance of a sum is in general not the sum of the variances. There’s an extra term.

To calculate the variance of a sum, we have to understand that extra term.

13.1.2Covariance

The covariance of XX and YY, denoted Cov(X,Y)Cov(X, Y), is the expected product of the deviations of XX and YY:

Cov(X,Y) = E(DXDY) = E((XμX)(YμY))Cov(X, Y) ~ = ~ E(D_XD_Y) ~=~ E\big( (X - \mu_X)(Y - \mu_Y) \big)

The expectation and variance of XX are based on the distribution of XX alone. The expectation and variance of YY are based on the distribution of YY alone. But covariance depends on the joint distribution of XX and YY and thus takes into account the relation between XX and YY.

Covariance has two main uses. First, it is a tool for calculating the variance of a sum. The fundamental calculation is the one we did above. Here is the result again, using the language of covariance.

Var(X+Y) = Var(X)+Var(Y)+2Cov(X,Y)Var(X+Y) ~ = ~ Var(X) + Var(Y) + 2Cov(X, Y)

The focus of this chapter is utilizing covariance to find variances of sums. But covariance has a second important application, which we will study later in the course. Here is a preview.

🎥 See More
Loading...

13.1.3Correlation

Covariance has strange units. If XX is measured in pounds and YY in inches then Cov(X,Y)Cov(X,Y) is measured in pound-inches which are hard to understand. But we can get rid of the units of covariance by dividing it by the two standard deviations, and then something wonderful happens.

Cov(X,Y)σXσY = E((XμX)(YμY))σXσY = E(XμXσXYμYσY)\frac{Cov(X, Y)}{\sigma_X\sigma_Y} ~ = ~ \frac{E\big( (X - \mu_X)(Y - \mu_Y) \big)}{\sigma_X\sigma_Y} ~ = ~ E \big( \frac{X-\mu_X}{\sigma_X} \cdot \frac{Y-\mu_Y}{\sigma_Y} \big)

This is the mean of the products of standard units which you will recognize from Data 8 as the definition of correlation.

The correlation between random variables XX and YY is defined as the normalized covariance:

r(X,Y) = Cov(X,Y)σXσYr(X, Y) ~ = ~ \frac{Cov(X, Y)}{\sigma_X\sigma_Y}

As you know, correlation is widely used in data analysis and inference. We will return to it when we study prediction. For now, you will just establish its basic properties in exercises.