This covariance calculator measures how two variables vary together: enter paired data to get the sample and population covariance, with the means and cross-product sum shown step by step.





Sample Covariance (n−1)–
Population Covariance (n)–
Σ(x−x̄)(y−ȳ)–
Direction–

What Is Covariance?

Covariance measures whether two variables deviate from their means in the same direction at the same time. Positive covariance: when X is above its mean, Y tends to be above its mean too. Negative: they move in opposition. Near zero: no consistent co-movement. Variance — from our Variance Calculator — is simply a variable's covariance with itself, which is why the formulas look like twins. This calculator is part of our Statistics Calculators collection.

The Covariance Formula

cov(X, Y) = Σ(x − x̄)(y − ȳ) ÷ (n − 1) for a sample (÷ n for a population).

Worked example (verified): X: 1, 2, 3, 4, 5 and Y: 2, 4, 5, 4, 5. Means: x̄ = 3, ȳ = 4. The cross-products (x−x̄)(y−ȳ) are: (−2)(−2) = 4, (−1)(0) = 0, (0)(1) = 0, (1)(0) = 0, (2)(1) = 2 → Σ = 6. Sample covariance = 6 ÷ 4 = 1.5; population covariance = 6 ÷ 5 = 1.2. Positive, as the mostly-together movement suggests.

Why Covariance Is Hard to Read (and Correlation Fixes It)

  • Covariance has units — X-units × Y-units — and no fixed scale: a covariance of 1.5 is huge for small numbers and nothing for stock prices.
  • Divide covariance by both standard deviations and you get the correlation coefficient r (here 1.5 ÷ (1.58 × 1.22) ≈ 0.77) — bounded, comparable, unit-free. That is the Correlation Calculator's job.
  • Covariance still matters directly: portfolio variance is built from asset covariances, and regression slopes are covariance ÷ variance.

Related Tools

Frequently Asked Questions

What does a covariance of 0 mean?

No linear co-movement between the variables in your data. (As with correlation, curved relationships can still exist.)

What is the difference between sample and population covariance?

The divisor: n − 1 for a sample (Bessel's correction, compensating for estimating the means) vs n for a complete population. This calculator reports both.

Can covariance be negative?

Yes — it means the variables tend to move in opposite directions, like umbrella sales and sunshine hours.

How are covariance and correlation related?

r = cov(X, Y) ÷ (σX × σY). Correlation is covariance rescaled onto the −1…+1 range.

What are the units of covariance?

The product of the two variables' units (e.g., dollars × hours). That unitfulness is why raw covariance values cannot be compared across data sets.

Is this covariance calculator free?

Yes — free, instant, no sign-up.