Covariance Calculator Online

This online covariance calculator gives the sample and population covariance of two variables, plus the correlation and a full table of the deviation products.

Checks on your data

Results

Sample covariance (n − 1)
13
Population covariance (n)
10.4
Correlation r
0.919239
Sign of the relationship
Positive: x and y tend to rise together
Means (x̄, ȳ)
6, 8
Standard deviations (sx, sy)
3.1623, 4.4721
Sum of products Σ(x − x̄)(y − ȳ)
52
Pairs (n)
5
Paired data
510246810xy
Calculation table
xyx − x̄y − ȳ(x − x̄)(y − ȳ)
23-4-520
47-2-12
650-30
811236
10144624
Show step-by-step solution
  1. x̄ = 6 and ȳ = 8.
  2. Multiply the deviations for each pair and add: Σ(x − x̄)(y − ȳ) = 52.
  3. Sample covariance = 52 ÷ (5 − 1) = 13.
  4. Population covariance = 52 ÷ 5 = 10.4.
  5. r = covariance ÷ (sx·sy) = 0.919239.
SampleΣ(x − x̄)(y − ȳ) / (n − 1)
PopulationΣ(x − μx)(y − μy) / N
Link to rr = cov / (sx·sy)

What Is Covariance?

Covariance measures how two variables move together. It is positive when they tend to be above or below their means at the same time, and negative when one tends to be high as the other is low.

Paste your x and y values in matching order. The calculator returns the sample covariance (dividing by n − 1), the population covariance (dividing by n), the correlation coefficient, the means and standard deviations, and a table of (x − x̄)(y − ȳ) for every pair.

The size of a covariance depends on the units of the data, so it is hard to compare across variables. Correlation divides out the units and always lies between −1 and 1, which is why the calculator reports both.

How to Use the Covariance Calculator

  1. Paste the x values and the y values in matching order.
  2. Read the sample covariance unless your data are the whole population.
  3. Use the correlation to judge how strong the relationship is.

Covariance Formula

Sample covariance

cov⁡(X,Y)=∑(xi−xˉ)(yi−yˉ)n−1\operatorname{cov}(X,Y)=\frac{\sum (x_i-\bar{x})(y_i-\bar{y})}{n-1}

Population covariance

σXY=∑(xi−μx)(yi−μy)N\sigma_{XY}=\frac{\sum (x_i-\mu_x)(y_i-\mu_y)}{N}

Correlation

r=cov⁡(X,Y)sxsyr=\frac{\operatorname{cov}(X,Y)}{s_x s_y}

Covariance Variables Explained

SymbolMeaningNotes
cov(X, Y)Covariance of x and y
x̄, ȳMeans of the two variables
nNumber of pairs
rCorrelation, cov(X, Y) / (sx·sy)Between −1 and 1

Covariance Worked Example

With the example values loaded in the calculator above, the steps are:

  1. x̄ = 6 and ȳ = 8.
  2. Multiply the deviations for each pair and add: Σ(x − x̄)(y − ȳ) = 52.
  3. Sample covariance = 52 ÷ (5 − 1) = 13.
  4. Population covariance = 52 ÷ 5 = 10.4.
  5. r = covariance ÷ (sx·sy) = 0.919239.

Result: Sample covariance (n − 1) = 13; Population covariance (n) = 10.4.

Worked example

For x = 2, 4, 6, 8, 10 and y = 3, 7, 5, 11, 14 the means are 6 and 8. The products of deviations are 20, 2, 0, 6 and 24, which add to 52.

Sample covariance = 52 ÷ 4 = 13. Population covariance = 52 ÷ 5 = 10.4. The standard deviations are 3.1623 and 4.4721, so r = 13 ÷ (3.1623 × 4.4721) = 0.9192.

Why covariance is hard to interpret on its own

The size of a covariance depends on the units of x and y. Measuring height in centimetres instead of metres multiplies it by 100. Correlation divides out the units, so it always lies between −1 and 1.

Where Covariance Is Used

Finance

Check how two returns move together before building a portfolio.

Statistics coursework

Verify each product of deviations in a covariance problem.

Preparing for regression

Look at the direction of the relationship before fitting a line.

Common Covariance Mistakes to Avoid

  • Covariance of a variable with itself is its variance.
  • Zero covariance means no linear relationship, but a curved relationship can still exist.

Covariance Terms and Definitions

Covariance
The average product of the deviations of two variables from their means.

Covariance FAQs

What is covariance?

It is a measure of how two variables vary together, built from the products of their deviations from the means.

What is the difference between sample and population covariance?

Sample covariance divides by n − 1 and population covariance divides by N.

What does negative covariance mean?

When one variable is above its mean, the other tends to be below its mean.

How is covariance different from correlation?

Correlation is covariance divided by both standard deviations. It is unitless and bounded between −1 and 1.

Can covariance be zero while the variables are related?

Yes, if the relationship is not linear, such as a U shape.

What is the covariance of X with itself?

Its variance.

Related calculators

Last updated 2026-11-09. See our disclaimer.