SOLVETUTORMATH SOLVER

Instrument MI-07-048 · Statistics

Covariance Calculator

Before you rescale it into a tidy −1-to-+1 correlation, there's covariance — the raw, unscaled measure of whether two variables move together. Enter paired x and y values and get both the sample and population versions.

Instrument MI-07-048
Sheet 1 OF 1
Rev A
Verified
Type 07 — Regression & Correlation SER. 2026-07048

Sample covariance

1.50000000

cov = Σ(x−x̄)(y−ȳ) / (n−1) [sample], / n [population]

1.20000000 Population covariance
The working Every figure verified twice
  1. n=5 -> sampleCov=1.500000, popCov=1.200000
Worksheet log
  1. No entries yet — change an input to log a scenario.

How this instrument works

Covariance measures whether two variables tend to move in the same direction or opposite directions, using their original units rather than a fixed scale. A positive covariance means that when x is above its own average, y also tends to be above its average (and both below together too) — the two rise and fall in step. A negative covariance means the opposite: when x is above its average, y tends to be below its, and vice versa. A covariance near zero means no clear directional pattern shows up between the two.

The calculation pairs each observation's deviation from its own variable's mean — how far this particular x is from x̄, and how far this particular y is from ȳ — and multiplies the two deviations together. When x and y move together, both deviations tend to share the same sign (both positive or both negative), so their product is positive; when they move oppositely, the signs tend to differ, making the product negative. Summing that product across every pair and dividing by a count gives the covariance.

This instrument reports both versions used in practice: sample covariance divides by n−1 (the number of pairs minus one), the standard adjustment used when your data is a sample meant to estimate a larger population's covariance; population covariance divides by n itself, appropriate when your data set already is the entire population of interest, not a sample from something larger. Unlike correlation, covariance's numeric value depends on the units of x and y — doubling every x value doubles the covariance, even though the underlying relationship hasn't changed — which is exactly why correlation exists as a separate, unit-free rescaling of the same underlying idea.

covsample=(xixˉ)(yiyˉ)n1,    covpop=(xixˉ)(yiyˉ)n\text{cov}_{\text{sample}} = \frac{\sum(x_i-\bar{x})(y_i-\bar{y})}{n-1}, \;\; \text{cov}_{\text{pop}} = \frac{\sum(x_i-\bar{x})(y_i-\bar{y})}{n}
x̄, ȳ — the means of the x and y series · n — the number of paired observations · Sxy — the sum of paired deviation products, positive when x and y tend to move together, negative when they tend to move oppositely · sample covariance, population covariance — the same Sxy divided by n−1 or n depending on whether the data is a sample or the full population.
  • Enter your first variable's values into x values, separated by commas, spaces, or new lines.
  • Enter the paired second variable's values, in matching order, into y values.
  • Both series need the same count of entries and at least 2 pairs.
  • Read Sample covariance if your data is a sample meant to estimate a larger population's relationship.
  • Read Population covariance instead if your data already represents the complete population you care about, not a sample from something bigger.

Worked example — the same five paired points as the correlation calculator

Using x = 1, 2, 3, 4, 5 and y = 2, 4, 5, 4, 5 — the same data set used in this site's correlation calculator, so the two results can be cross-checked directly — the instrument finds x̄ = 3 and ȳ = 4, then computes the sum of paired deviation products: Sxy = (1−3)(2−4) + (2−3)(4−4) + (3−3)(5−4) + (4−3)(4−4) + (5−3)(5−4) = 4+0+0+0+2 = 6.

Sample covariance reads 1.5, computed as 6/(5−1) = 6/4. Population covariance reads 1.2, computed as 6/5. Both are positive, confirming x and y move together on balance — consistent with the positive Pearson correlation coefficient (r ≈ 0.77) this site's correlation calculator reports for the identical pair of series, since covariance and correlation always share the same sign.

Questions

Should I use sample or population covariance?

Use sample covariance whenever your data is a subset drawn from a larger group you're trying to draw conclusions about — the n−1 divisor corrects for the fact that a sample's own mean tends to slightly understate the true spread. Use population covariance only when your data set already is the entire group you care about, with nothing left out — in that case there's no larger population being estimated, so no correction is needed. When in doubt, sample covariance is the more common and generally safer default.

How is covariance different from correlation?

Covariance keeps the original units of x and y multiplied together, which makes its raw numeric size hard to interpret or compare across different variable pairs — a covariance of 1.5 could mean a strong or weak relationship depending entirely on the scale of the underlying data. This site's separate correlation calculator divides that same covariance by the standard deviations of x and y, rescaling it into the fixed −1-to-+1 range of Pearson's r, which is directly comparable across any two variables regardless of units.

Why does the sample covariance divide by n−1 instead of n?

Because a sample's own mean is calculated from that same sample, which makes the sample slightly more 'self-consistent' than the true population it's drawn from — deviations measured from a sample's own mean tend to be a bit smaller, on average, than deviations from the true population mean would be. Dividing by n−1 instead of n corrects for that small downward bias, producing an unbiased estimate of the population's covariance from sample data alone.

Can covariance be zero even when x and y are related?

Yes — like correlation, covariance specifically detects a linear (straight-line) tendency for x and y to move together, and it can come out at or near zero even when a strong non-linear relationship exists between the two variables. A symmetric curved pattern, for instance, can have positive and negative deviation products cancel out almost entirely, leaving a near-zero covariance despite an obviously real underlying relationship.

What does the sign of covariance mean if the two variables use very different units?

The sign — positive or negative — still means exactly the same thing regardless of units: positive means the two variables tend to rise and fall together, negative means they tend to move in opposite directions. What changes with different units is the magnitude, which scales directly with whatever units x and y are measured in, so the raw covariance number itself shouldn't be compared across data sets with different units — that's what correlation is for instead.

References