Skip to content
CalculatorAtlas

Covariance Calculator

Tested

Sample and population covariance.

Tested, not yet published. The formula for this calculator is implemented and passes its automated checks. This page stays non-indexable until it is reviewed and published.

Results

Enter your values and press Calculate. Results appear here.

  • • Result

Quick answer

Covariance is cov = Σ(x − x̄)(y − ȳ) ÷ (n − 1) for a sample or ÷ n for a population. For x = 1 to 5 and y = 2, 4, 5, 4, 5 the sample covariance is 1.5 and the population covariance 1.2.

Enter equal-length x and y lists. The calculator returns the sample and population covariance.

Related tools: Least Squares Regression Calculator: Fit the least-squares regression line to paired data and read off the slope, intercept and a prediction. Correlation Coefficient Calculator: Pearson correlation of two variables. Linear Regression Calculator: Least-squares line y = a + bx through paired data.

How to use the Covariance Calculator

  1. Type x values, for example 1, 2, 3, 4, 5.
  2. Type y values, for example 2, 4, 5, 4, 5.
  3. Press Calculate to see the result, and use Reset to start again.
Inputs of the Covariance Calculator
InputWhat to enterAllowed values
x valuesText, such as 1, 2, 3, 4, 5—
y valuesText, such as 2, 4, 5, 4, 5—

Formula and method

Formula

cov = Σ(x − x̄)(y − ȳ) ÷ (n − 1) (sample) or ÷ n (population)

IEEE-754 double precision; shown to at most 6 decimal places.

Computed from deviations from the means.

Worked examples

This example is verified: each one is an automated test case that the live calculator must reproduce exactly.

Example 1

Inputs: x values = 1,2,3,4,5; y values = 2,4,5,4,5.

Results of example 1
ResultValue
Sample covariance1.5
Population covariance1.2

The first line is the headline result (sample covariance). Below it the covariance Calculator lists population covariance, which describe the same case from other angles. IEEE-754 double precision; shown to at most 6 decimal places.

What it tells you

A positive covariance means the variables tend to rise together. Its size depends on units, so it can't be compared across data sets; correlation standardises it: r = cov ÷ (sₓ s_y).

Sample or population

Use n − 1 for a sample (the unbiased estimate) and n for a full population. Here the sum of cross-products is 6, so 6 ÷ 4 = 1.5 and 6 ÷ 5 = 1.2.

What happens with invalid input

These messages are produced by the calculator itself, so you know what to fix.

  • y values: entering "1" shows "Enter at least 2 numbers." beside that field and no result.

Choosing between the Covariance Calculator and similar calculators

Each row shows what a related calculator on this site asks for and what it returns, so you can pick the one that matches your question.

Choosing between the Covariance Calculator and similar calculators
CalculatorYou enterIt returns
[Least Squares Regression Calculator](/statistics/least-squares-regression/)x values and y valuesRegression line
[Correlation Coefficient Calculator](/statistics/correlation-coefficient-calculator/)x values and y valuesCorrelation r
[Linear Regression Calculator](/statistics/linear-regression-calculator/)x values and y valuesRegression line
[R-Squared Calculator](/statistics/r-squared-calculator/)x values and y valuesR²
[Multiple Linear Regression Calculator](/statistics/multiple-regression-calculator/)response values and predictor 1Coefficients (intercept, b₁, b₂ …)

Background: regression and correlation

Least squares chooses the line that minimises the sum of the squared vertical distances from the points. The slope is the sum of the cross-products of the deviations divided by the sum of the squared x deviations, and the intercept is the mean of y minus the slope times the mean of x.

For simple regression R² is the square of the correlation coefficient r, the share of the variation in y that the line explains. R² has no sign, so the sign of the slope tells you whether the relationship rises or falls. A strong fit does not prove one variable causes the other.

Assumptions and limitations

  • Equal-length lists

If a required value is empty, not a number, or outside its allowed range, the form marks that field with a message and shows no result instead of a misleading number. The automated checks deliberately try invalid entries for y values to confirm this.

Frequently asked questions

Can covariance be negative?

Yes, when one rises as the other falls.

What is the covariance of x with itself?

The covariance of x with itself is its variance, so cov(x, x) = s².

Does zero covariance mean independence?

Not necessarily: variables can be dependent in a non-linear way (such as y = x² on symmetric data) and still have zero covariance.

What does the Covariance Calculator calculate?

Sample and population covariance. It returns Sample covariance and Population covariance.

What formula does the Covariance Calculator use?

cov = Σ(x − x̄)(y − ȳ) ÷ (n − 1) (sample) or ÷ n (population). Computed from deviations from the means.

What do I need to enter in the covariance Calculator?

You enter x values and y values.

How is the result rounded or limited?

IEEE-754 double precision; shown to at most 6 decimal places. Equal-length lists.

What is an example of a covariance result?

With x values 1,2,3,4,5 and y values 2,4,5,4,5, the sample covariance is 1.5.

Sources

  • NIST/SEMATECH e-Handbook of Statistical Methods (itl.nist.gov/div898/handbook)
  • Standard textbook definitions (e.g. Moore, McCabe & Craig, Introduction to the Practice of Statistics)

Content last reviewed 2026-11-04. Formulas and worked examples are checked by automated tests against independently computed values.