01 · Learning path
Covariance
Measures how two variables move together relative to their means; it is the basis of correlation and PCA.
Covariance tells you how much two random variables vary together around their respective means. It is the basic ingredient for describing a linear relationship between two quantities.
What the sign tells us
The numerical value depends on the units of the variables, so it is rarely interpreted on its own. The sign, however, is informative:
- Positive: when one variable goes up, the other tends to go up.
- Negative: when one variable goes up, the other tends to go down.
- Close to zero: there is no obvious linear trend.
Definition
For a sample of
where
Relationship with variance
If you compute the covariance of a variable with itself, you get its variance:
Example
If you look at advertising spend (
Applications
Covariance appears in portfolio calculations in finance, in the covariance matrix used by PCA, and in the definition of correlation, which is its unit-free version.