Covariance Calculator

Calculate the covariance between two variables, with the correlation coefficient that makes the number interpretable.

Separate values with commas, spaces or new lines.
Separate values with commas, spaces or new lines.
Sample covariance 14
cov(X,Y) = Σ (xᵢ − x̄)(yᵢ − ȳ) / (n − 1) for a sample, / n for a population
Population covariance 11.66666667
cov(X,Y) = Σ (xᵢ − x̄)(yᵢ − ȳ) / (n − 1) for a sample, / n for a population
Correlation coefficient r 0.99061012
cov(X,Y) = Σ (xᵢ − x̄)(yᵢ − ȳ) / (n − 1) for a sample, / n for a population
Paired values 6
Mean of X 7
Mean of Y 9.666667
What it means A strong positive linear relationship (r = 0.9906). Correlation is not causation.

Everything you type here is processed on your own device. No input is sent to a server, logged, or stored.

What the Covariance Calculator does

The covariance calculator on this page will calculate the covariance between two variables, with the correlation coefficient that makes the number interpretable. Fill in all 2 fields and the result updates as you type — there is no Calculate button to press and no page reload. It is most often used for measuring whether two measurements vary together. If you want to cross-check the result, there is another covariance calculator on FreeToolsWorld.org.

How to use it

  1. Paste your X values, separated by commas, spaces or new lines.
  2. Paste the matching Y values in the same order, one for each X.
  3. Read the sample covariance, or the population covariance if your data is the complete set.
  4. Use the correlation coefficient beneath it to judge how strong the relationship is, since covariance alone has no scale.

How it works

Covariance measures whether two variables move together. For each pair it multiplies the deviation of x from its mean by the deviation of y from its mean: when both are above average or both below, the product is positive; when they move in opposite directions it is negative. Averaging those products gives a single number whose sign tells you the direction of the relationship.

Its magnitude, unfortunately, tells you almost nothing on its own, because it carries the units of both variables multiplied together. A covariance of 240 between height in centimetres and weight in kilograms becomes 2400 if you switch to millimetres, without the relationship changing at all. That is why the correlation coefficient exists: dividing the covariance by both standard deviations strips out the units and forces the answer between −1 and +1, where it can actually be compared.

The sample version divides by n − 1 rather than n. Using the sample means to measure deviations from uses up one degree of freedom and makes the sum of products slightly too small; dividing by n − 1 corrects that bias. Spreadsheets expose both — Excel's COVARIANCE.S and COVARIANCE.P — and picking the wrong one on a small sample shifts the answer noticeably.

When to use it

  • Measuring whether two measurements vary together.
  • Calculating portfolio covariance between two asset returns.
  • Checking a covariance figure from a spreadsheet or statistics package.
  • Preparing the inputs for a regression or a covariance matrix.

Common mistakes to avoid

  • Interpreting the size of a covariance. Only its sign is meaningful without the units; use the correlation for magnitude.
  • Mismatching the two lists so pairs line up wrongly. Every x must sit opposite its own y.
  • Reading a strong correlation as proof that one variable causes the other.

Frequently asked questions

What is the difference between covariance and correlation?

They measure the same relationship, but correlation is standardised. Divide the covariance by the product of the two standard deviations and you get r, which always falls between −1 and +1 and is unaffected by the units.

Should I use n or n − 1?

Use n − 1 when your data is a sample and you want to estimate the covariance of a larger population, which is nearly always. Use n only when you genuinely have the whole population.

Can covariance be zero when the variables are clearly related?

Yes. Covariance only detects linear association. A perfect U-shaped relationship can have a covariance of exactly zero, which is why plotting the data matters as much as calculating the statistic.

Related tools

See all math & statistics calculators →