Paste paired x and y values to get the sample and population covariance, with each step in a table and the correlation alongside.
How covariance is calculated
Covariance measures whether two variables move together. For each pair, multiply how far x is from its mean by how far y is from its mean. Then average those products.
Sample: sxy = Σ(x − x̄)(y − ȳ) ÷ (n − 1)
Population: σxy = Σ(x − μx)(y − μy) ÷ n
Use the sample version when your pairs are a sample from a larger group, which is most real data. It matches Excel's COVARIANCE.S. The population version matches COVARIANCE.P.
Worked example
Take x = 2, 4, 6, 8 and y = 1, 3, 2, 5 (filled in above). The means are x̄ = 5 and ȳ = 2.75.
- Deviations of x: −3, −1, 1, 3. Deviations of y: −1.75, 0.25, −0.75, 2.25.
- Products: 5.25, −0.25, −0.75 and 6.75, which add up to 11.
- Sample covariance = 11 ÷ 3 ≈ 3.66667. Population covariance = 11 ÷ 4 = 2.75.
Microsoft's own example for COVARIANCE.S, x = 2, 4, 8 and y = 5, 11, 12, gives 9.666666667, and so does this calculator.
Reading the answer
- Positive covariance: x and y tend to be above (or below) their means together. Negative: one tends to be high when the other is low.
- The size depends on the units. Measuring in cents instead of dollars multiplies it by 100, so you can't tell "strong" from the number alone. Divide by both standard deviations to get the correlation r, which is always between −1 and 1. The result shows r for you.
- A covariance near 0 means no straight-line relationship, but there could still be a curved one.
Sources
How we checked this
Before every update, this calculator is run in a real browser with these known answers, and it must match all of them:
- x 2, 4, 6, 8 and y 1, 3, 2, 5: sample covariance 11/3 ✓
- Same data, population: 11/4 = 2.75 ✓
- Microsoft's COVARIANCE.S example: 9.666666667 ✓
- Edge: a constant y gives covariance 0 ✓
- Edge: one pair can't give a sample covariance ✓
Last checked October 26, 2026. Spotted something wrong? The math is done in your browser with the formula shown on this page, so you can check any result by hand.
Questions people ask
What's the difference between sample and population covariance?
Sample covariance divides by n − 1 and population covariance divides by n. Use sample covariance when your data is a sample from something larger.
Can covariance be negative?
Yes. A negative covariance means that when one variable is above its mean, the other tends to be below its mean, like outdoor temperature and heating bills.
How is covariance related to correlation?
Correlation is covariance divided by the product of the two standard deviations: r = sxy ÷ (sx × sy). That removes the units and puts the answer between −1 and 1.
What does a covariance of 0 mean?
There's no straight-line tendency for the variables to move together. They might still be related in a curved way, so a zero covariance doesn't prove independence.
What is the covariance of a variable with itself?
Its variance. Cov(x, x) = Σ(x − x̄)² ÷ (n − 1), the sample variance.