What is covariance?

Covariance is a measure of the joint variability of two random variables.

The correlation between two random variables is a dimensionless measure of the strength of the linear relationship between them. The covariance is a measure that takes the correlation and scales it by a number that represents the combined spread of the two random variables.

The covariance between two variables is positive when they tend to move in the same direction and negative if they tend to move in opposite directions.

To see how we arrive at the definition, first think about two variables each with mean zero. That is, each variable could be positive or negative but is on average zero. To summarize whether the two variables move together, we can look at the product:

- When both variables have the same sign, it’s positive;
- When they have opposite signs, it’s negative;
- When they are both large and have the same sign, you get a big positive number;
- When they are both large and have opposite signs, you get a big negative number;