Covariance Calculator
How two variables move together — the sample and population covariance, with the correlation coefficient that puts it on a readable scale.
Covariance is the average product of the two variables' deviations from their means: positive when they rise together, negative when one rises as the other falls.
How the covariance calculator works
Covariance is the average product of the two variables' deviations from their means: positive when they rise together, negative when one rises as the other falls. Dividing by n − 1 gives the sample version.
On its own the number is hard to read, because it carries the units of both variables multiplied together. Dividing by both standard deviations gives the correlation coefficient, which is bounded to −1…+1 and is what you should usually quote.
Formula: cov = Σ(xᵢ − x̄)(yᵢ − ȳ) / (n − 1); r = cov / (sₓ s_y)
Worked examples
| Inputs | Sample covariance | Note |
|---|---|---|
| Five pairs | 1.5 | covariance 1.5, r = 0.775 |
| Perfectly linear | 3.333333 | r = 1 |
| Perfectly inverse | -3.333333 | r = −1 |
FAQFrequently asked questions
What does covariance tell me?
The direction two variables move together in. Positive means they rise together; negative means one falls as the other rises.
Why is the number so hard to interpret?
Because it carries both variables' units multiplied. Covariance of height and weight is in centimetre-kilograms, which means nothing on its own.
Should I use correlation instead?
Usually yes. It is covariance scaled to −1…+1, so it is comparable across any pair of variables.
What does zero covariance mean?
No *linear* relationship. Variables can be perfectly related in a curved way and still have zero covariance.
Why divide by n − 1?
Bessel's correction — the same reason as for the sample variance. Using the sample means makes the deviations slightly too small.
Where these figures come from
- NIST Digital Library of Mathematical Functions — reference definitions for elementary and special functions
- Wolfram MathWorld — definitions and formulas for every topic on this page
- NIST/SEMATECH e-Handbook of Statistical Methods — the statistical formulas (mean, variance, z, confidence intervals, sample size)
- National curriculum in England — Mathematics — the terms and methods taught in UK schools
Last checked: September 2026. Formulas are fixed by mathematics and do not change with tax years or regulations.