Skip to content

Covariance Calculator

Paste paired x and y values and get the sample covariance (dividing by n − 1) and the population covariance (dividing by n), with a table of every deviation and product. The calculator explains what the sign tells you, why the size of a covariance is hard to read on its own, and gives Pearson's r alongside.

Data entry

0 values

0 values

Enter at least two (x, y) pairs to compute the covariance.

How to Use the Covariance Calculator

  1. 1. Enter the pairs. Type the x values and y values as two lists in the same order, or switch to one "x, y" pair per line — handy when pasting two columns from a spreadsheet.
  2. 2. Check the count. Both lists must hold the same number of values; each x is paired with the y in the same position.
  3. 3. Read both covariances. Use the sample covariance for a sample from a larger population — the usual case in research — and the population covariance when your pairs are the whole population.
  4. 4. Follow the table. Each row shows the two deviations from the means and their product; the products sum to the numerator of the formula.

The Covariance Formula

Covariance measures whether two variables move together. For each pair, take how far x sits from its mean and how far y sits from its mean, and multiply. The product is positive when both are above their means or both below, and negative when one is above and the other below. Averaging the products gives the covariance:

Sample

sxy = Σ(x − x̄)(y − ȳ) ÷ (n − 1)

Population

σxy = Σ(x − μx)(y − μy) ÷ N

The sample version divides by n − 1 for the same reason the sample variance does: deviations from the sample means run slightly small, and n − 1 corrects the bias. In fact the covariance of a variable with itself is its variance.

Worked Example

Five students report hours of revision (x) and exam scores (y). The means are x̄ = 6 hours and ȳ = 75 points:

x (hours)y (score)x − x̄y − ȳ(x − x̄)(y − ȳ)
265−4−1040
470−2−510
6720−30
8812612
108741248

Sum of the products: 110.

Sample covariance = 110 ÷ (5 − 1) = 27.5; population covariance = 110 ÷ 5 = 22. Every product is zero or positive, so the sign is clearly positive: students who revised more scored higher. Dividing the covariance by the variance of x, 10, also gives the slope of the regression line — 2.75 points per extra hour.

Why the Size of a Covariance Is Hard to Interpret

The covariance is measured in units of x times units of y — here, hour-points. Record revision time in minutes instead of hours and the covariance jumps from 27.5 to 1,650, although nothing about the relationship has changed. So the sign of a covariance is meaningful, but its size cannot tell you whether a relationship is strong or weak, and you cannot compare covariances across studies with different units.

Correlation fixes this by dividing out both standard deviations: r = sxy ÷ (sx × sy) = 27.5 ÷ (3.1623 × 8.86) ≈ 0.98, in hours or in minutes. When you want to say how strongly two variables are related, report r — the Correlation Calculator gives it with an interpretation — and keep the covariance for the formulas that need it, such as regression slopes and portfolio variance.

Frequently Asked Questions

What does covariance tell you?
It tells you the direction of the linear relationship between two variables. A positive covariance means they tend to rise together, a negative one means one tends to fall as the other rises, and a value near zero means no linear pattern. Its size depends on the units, so it does not measure strength.
What is the difference between covariance and correlation?
Correlation is covariance rescaled by the two standard deviations, which makes it unit-free and confines it between −1 and +1. Covariance has the same sign as the correlation but can be any size, so only the correlation can be compared across datasets or read as weak or strong.
Should I use sample or population covariance?
Use the sample covariance, dividing by n − 1, when your data are a sample and you want to estimate the relationship in a larger population — almost always the case in research. Use the population covariance, dividing by n, only when you have every member of the population. Excel's COVARIANCE.S and COVARIANCE.P make the same split.
Can covariance be negative?
Yes. A negative covariance means that above-average values of one variable tend to occur with below-average values of the other — hours of screen time and hours of sleep, for example. There is no lower or upper limit on its size.
Does a covariance of zero mean the variables are independent?
No. A zero covariance means there is no linear relationship. Variables can be strongly related in a curved way — y = x² over a range symmetric around zero is the classic case — and still have a covariance of exactly zero. Independent variables do always have zero covariance.
How is covariance related to the regression slope?
The least-squares slope of y on x is the covariance divided by the variance of x: b = covariance(x, y) ÷ variance(x). In the worked example that is 27.5 ÷ 10 = 2.75 points per hour, the same slope the Linear Regression Calculator reports for those data.

Related Tools

More in Statistics Calculators

See all Statistics Calculators