Find out whether two variables move together. Enter paired X and Y values to get the sample or population covariance, plus the correlation that puts it on a −1 to 1 scale.
cov(X, Y) = Σ(x − x̄)(y − ȳ) ÷ (n − 1)
One value per observation.
In the same order as X, so each pair lines up.
Covariance measures whether two variables tend to move in the same direction. It's positive when above-average X values go with above-average Y values, negative when they go with below-average Y values, and close to zero when there's no straight-line pattern.
The sign is easy to read; the size isn't. Covariance comes out in the product of the two units (hours × marks, say), so the same relationship gives a covariance 60 times bigger if you record time in minutes instead of hours. To judge strength, divide by both standard deviations to get the correlation coefficient, which always lies between −1 and 1.
Covariance still matters in its own right. Portfolio risk in finance is built from the covariances between assets, error propagation uses it when measurements are linked, and it's the raw ingredient of both correlation and regression slopes.
Definitions as given in the NIST/SEMATECH e-Handbook of Statistical Methods. See Sources.
A pair where both are above (or both below) their means gives a positive product. A pair split either side gives a negative one.
The covariance of a variable with itself is its variance: cov(X, X) = var(X).
Positive, so more study goes with higher scores. The 1.5 on its own says nothing about strength; the correlation of 0.77 says the link is fairly strong. The population covariance would be 6 ÷ 5 = 1.2.
The worked example with study time recorded in different units. The covariance moves every time; the correlation never does.
| Study time in | Covariance | Correlation |
|---|---|---|
| Hours | 1.5 | 0.7746 |
| Minutes | 90 | 0.7746 |
| Days | 0.0625 | 0.7746 |
Correlation is covariance divided by both standard deviations. That removes the units and puts the result between −1 and 1, so strengths can be compared.
No. It only says they move together. Both might be driven by something else, or the pattern might be chance.
Yes. Negative covariance means high values of one tend to go with low values of the other, like outdoor temperature and heating bills.
Its size can’t exceed √(var X × var Y). That limit is exactly what keeps correlation between −1 and 1.
Use the sample version (n − 1) when your pairs are a sample from something larger, which is almost always. Use n only when you have every member of the population.
Portfolio variance is built from the covariances between assets. Assets with negative covariance offset each other, which is the basis of diversification.
A table of covariances between every pair of several variables, with the variances down the diagonal. It’s the starting point for principal component analysis and many multivariate methods.
=COVARIANCE.S(x_range, y_range) for a sample or =COVARIANCE.P(x_range, y_range) for a population. Both ranges must be the same length.
Related Tools