Statistics Reference

Covariance vs Correlation

They measure the same thing — how two variables move together — at two different levels of finish. Covariance is the raw co-movement, wearing the units of both variables; correlation is the same quantity standardized to a clean −1 to +1 scale. This guide carries one dataset through both computations and marks where each is the right tool.

Side by Side

 CovarianceCorrelation (Pearson r)
FormulaΣ(x−x̄)(y−ȳ)/(n−1)cov(x,y) / (sₓ sỹ)
Unitsunits of x × units of yNone — a pure number
RangeUnbounded−1 to +1
Comparable across datasets?No — scale-dependentYes — that is its purpose
Main useComputation: portfolios, variances of sums, regression internalsCommunication: strength and direction of a linear relationship

One Dataset, Both Numbers

Study hours and exam scores for five students: (2, 65), (4, 70), (6, 75), (8, 85), (10, 90). Means: x̄ = 6 hours, ȳ = 77 points.

  1. Cross-products: (−4)(−12) + (−2)(−7) + 0 + (2)(8) + (4)(13) = 48 + 14 + 0 + 16 + 52 = 130.
  2. Sample covariance: 130 / (5 − 1) = 32.5 hour·points — positive, so hours and scores rise together. But is 32.5 strong? The units make it impossible to say.
  3. Standard deviations: sₓ = √(40/4) = 3.162 hours; sỹ = √(430/4) = 10.368 points.
  4. Correlation: r = 32.5 / (3.162 × 10.368) = 0.9912 — now the verdict is readable: an almost perfectly linear relationship.

The covariance calculator and correlation calculator reproduce both numbers from the same pairs — the covariance tool reports r alongside, precisely because raw covariance is so hard to judge alone.

The Units Argument

Why is 32.5 unreadable? Measure study time in minutes instead of hours and every x-deviation multiplies by 60: the covariance becomes 1,950 minute·points — same data, same relationship, sixty times the number. Correlation is immune: sₓ also multiplies by 60, and the ratio r stays exactly 0.9912. Dividing by both standard deviations strips the units and the arbitrary scales with them.

That immunity has a price: r throws away the units that prediction needs. The regression slope restores them — b = cov(x,y)/var(x) = 130/40 = 3.25 points per hour, or equivalently r × (sỹ/sₓ). Strength lives in r; exchange rates between variables live in the slope. The regression calculator reports both.

When Covariance Is the Right Tool

  • Portfolio risk. The variance of a two-asset portfolio is w₁²σ₁² + w₂²σ₂² + 2w₁w₂·cov — the covariances (not correlations) carry the diversification math.
  • Variances of sums. var(x + y) = var(x) + var(y) + 2cov(x, y): ignoring the covariance term is the classic error in combining correlated measurements.
  • Model internals. Regression coefficients, principal components, and Kalman filters all consume covariance matrices; correlation matrices are those same objects standardized for human reading.

And one caveat both numbers share: they detect only linear co-movement, and neither implies causation — the full argument lives in the correlation-vs-causation guide.

Try the Covariance Calculator

Sample or population covariance from paired data, with Pearson r reported alongside — the worked example automated.

Frequently Asked Questions

What is the difference between covariance and correlation?

Both measure how two variables move together, but covariance is unstandardized - its size depends on the variables' units and spreads - while correlation divides covariance by both standard deviations, producing a unitless number locked between -1 and +1. Correlation is covariance made comparable across datasets.

Why is correlation always between -1 and +1 while covariance is unbounded?

The Cauchy-Schwarz inequality guarantees that covariance can never exceed the product of the two standard deviations in absolute value. Dividing by that product therefore caps the ratio at +/-1, with the extremes reached exactly when the points lie on a perfect straight line. Covariance itself has no such natural scale - rescale a variable and its covariances rescale with it.

Can covariance and correlation have different signs?

No - correlation is covariance divided by two standard deviations, which are always positive, so the sign passes through unchanged. Positive means the variables tend to rise together, negative means one tends to fall as the other rises, and zero means no linear tendency either way.

If correlation is easier to interpret, why does covariance exist at all?

Because covariance is the quantity that arithmetic works on. Portfolio variance combines asset covariances (not correlations) with weights; the variance of a sum is the sum of variances plus twice the covariance; regression slopes and principal components are built from covariance matrices. Correlation is for communicating strength; covariance is for computing with.

Does a covariance of zero mean the variables are independent?

No. Zero covariance (and zero correlation) only rules out a linear relationship. A perfect U-shaped dependence - like y = x^2 over symmetric x values - produces covariance of exactly zero while y is completely determined by x. Independence implies zero covariance, but the reverse fails; always plot the data.

Which one does the regression slope use?

The simple regression slope is covariance divided by the variance of x: b = cov(x,y)/var(x). Equivalently it is r x (sy/sx) - correlation rescaled back into the variables' units. That identity shows the division of labor: r carries the strength of the relationship, and the standard deviations restore the units that prediction needs.