What Is Covariance?
Covariance measures how two variables move together. It is positive when they tend to be above or below their means at the same time, and negative when one tends to be high as the other is low.
Paste your x and y values in matching order. The calculator returns the sample covariance (dividing by n − 1), the population covariance (dividing by n), the correlation coefficient, the means and standard deviations, and a table of (x − x̄)(y − ȳ) for every pair.
The size of a covariance depends on the units of the data, so it is hard to compare across variables. Correlation divides out the units and always lies between −1 and 1, which is why the calculator reports both.
How to Use the Covariance Calculator
- Paste the x values and the y values in matching order.
- Read the sample covariance unless your data are the whole population.
- Use the correlation to judge how strong the relationship is.
Covariance Formula
Sample covariance
Population covariance
Correlation
Covariance Variables Explained
| Symbol | Meaning | Notes |
|---|---|---|
| cov(X, Y) | Covariance of x and y | |
| x̄, ȳ | Means of the two variables | |
| n | Number of pairs | |
| r | Correlation, cov(X, Y) / (sx·sy) | Between −1 and 1 |
Covariance Worked Example
With the example values loaded in the calculator above, the steps are:
- x̄ = 6 and ȳ = 8.
- Multiply the deviations for each pair and add: Σ(x − x̄)(y − ȳ) = 52.
- Sample covariance = 52 ÷ (5 − 1) = 13.
- Population covariance = 52 ÷ 5 = 10.4.
- r = covariance ÷ (sx·sy) = 0.919239.
Result: Sample covariance (n − 1) = 13; Population covariance (n) = 10.4.
Worked example
For x = 2, 4, 6, 8, 10 and y = 3, 7, 5, 11, 14 the means are 6 and 8. The products of deviations are 20, 2, 0, 6 and 24, which add to 52.
Sample covariance = 52 ÷ 4 = 13. Population covariance = 52 ÷ 5 = 10.4. The standard deviations are 3.1623 and 4.4721, so r = 13 ÷ (3.1623 × 4.4721) = 0.9192.
Why covariance is hard to interpret on its own
The size of a covariance depends on the units of x and y. Measuring height in centimetres instead of metres multiplies it by 100. Correlation divides out the units, so it always lies between −1 and 1.
Where Covariance Is Used
Finance
Check how two returns move together before building a portfolio.
Statistics coursework
Verify each product of deviations in a covariance problem.
Preparing for regression
Look at the direction of the relationship before fitting a line.
Common Covariance Mistakes to Avoid
- Covariance of a variable with itself is its variance.
- Zero covariance means no linear relationship, but a curved relationship can still exist.
Covariance Terms and Definitions
- Covariance
- The average product of the deviations of two variables from their means.
Covariance FAQs
What is covariance?
It is a measure of how two variables vary together, built from the products of their deviations from the means.
What is the difference between sample and population covariance?
Sample covariance divides by n − 1 and population covariance divides by N.
What does negative covariance mean?
When one variable is above its mean, the other tends to be below its mean.
How is covariance different from correlation?
Correlation is covariance divided by both standard deviations. It is unitless and bounded between −1 and 1.
Can covariance be zero while the variables are related?
Yes, if the relationship is not linear, such as a U shape.
What is the covariance of X with itself?
Its variance.