Covariance Calculator
Test cases replayed : 3 of 3 match · Methodology · No outside source listed
Paste two lists of paired values, x and y, in the same order to measure how they vary together.
Result
Sample covariance
Population covariance
- Pearson correlation coefficient (r)
- Number of pairs
- Note
Estimate for planning only, not tax, legal, financial or medical advice. This calculator uses the method explained on this page.
This browser did not allow copying. The sentence is in the box below, already selected: copy it with your keyboard or the menu.
How to use this calculator
Fill in the fields in this order; each step takes you to its field.
- x values (separated by commas, spaces or new lines): type or paste your values.
- y values, same order and count: type or paste your values.
- Read the result: Sample covariance; the panel also shows Population covariance, Pearson correlation coefficient (r), Number of pairs and Note.
Data plot
Table of values
| x | y |
|---|
How this calculator works
Sample covariance = Σ(xᵢ − x̄)(yᵢ − ȳ) ÷ (n − 1), where x̄ and ȳ are the means of the two lists and n is the number of pairs. Population covariance divides the same sum by n.
A positive covariance means the two variables tend to rise together, a negative one that one rises when the other falls. Its size depends on the units, so the correlation r = covariance ÷ (sₓ × s_y), which is unit-free and lies between −1 and 1, is shown as well.
Worked example
| x values (separated by commas, spaces or new lines) | 2, 4, 6, 8, 10 |
|---|---|
| y values, same order and count | 1, 3, 2, 5, 4 |
| Sample covariance | 4 |
|---|---|
| Population covariance | 3.2 |
| Pearson correlation coefficient (r) | 0.8 |
| Number of pairs | 5 |
Frequently asked questions
What is the covariance of x = 2, 4, 6, 8, 10 and y = 1, 3, 2, 5, 4?
The means are 6 and 3, the cross-products of deviations add up to 16, so the sample covariance is 16 ÷ 4 = 4 and the population covariance 16 ÷ 5 = 3.2.
What is the difference between covariance and correlation?
Covariance is in the product of the two units and has no fixed range. Correlation divides it by both standard deviations, giving a number between −1 and 1 that can be compared across data sets.