Covariance Calculator
Measure how two sets of paired numbers move together.
What it does
Covariance describes the direction of a relationship between two variables. A positive value means that large values of one tend to occur with large values of the other, while a negative value means they tend to move in opposite directions.
This calculator takes two comma separated lists of equal length and returns the sample covariance. It also shows how many pairs were found and the mean of each list, so the calculation can be reproduced by hand.
The default lists are X equal to 1, 2, 3, 4, 5 and Y equal to 2, 4, 5, 4, 5. The means are 3 and 4, the cross products sum to 6, and dividing by four pairs of degrees of freedom gives 1.5000.
Because covariance uses the original units of both variables, its magnitude is hard to compare across datasets. Correlation rescales it to a number between minus one and one and is often more useful for comparison.
A covariance near zero means there is no linear tendency to move together, but it does not rule out a nonlinear relationship. The measure also assumes each pair of observations is matched correctly.
How to use
- Prepare two lists of numbers with one Y value for each X value.
- Enter the X list as numbers separated by commas.
- Enter the Y list in the same order.
- Press calculate and read the sample covariance.
- Check the pair count and the two means.
- Use correlation if you need a scale free comparison.
Formula
- xᵢ, yᵢ
- The paired observations in the two lists.
- mean X, mean Y
- The arithmetic mean of each list.
- n
- The number of paired observations.
- cov
- Sample covariance in the product of the two variable units.
The tool uses the sample form with n minus one in the denominator. Each list must contain at least two numbers and both lists must have the same length. Only plain decimal numbers separated by commas are accepted, so remove currency symbols and thousands separators first.
Worked example
Example: five paired values
The form opens on these lists so the result is already shown.
- List X is 1, 2, 3, 4, 5 and list Y is 2, 4, 5, 4, 5.
- Mean X is 3 and mean Y is 4.
- Cross products are 4, 0, 0, 0 and 2, which sum to 6.
- Divide by n minus one, which is 4, to get 1.5.
- The tool shows 1.5000, 5, 3.0000 and 4.0000.
Reference table
| X list | Y list | Covariance | Direction |
|---|---|---|---|
| 1, 2, 3 | 3, 2, 1 | -1.0000 | Moves oppositely |
| 1, 2, 3 | 1, 2, 3 | 1.0000 | Moves together |
| 10, 20, 30, 40 | 5, 10, 15, 20 | 83.3333 | Moves together |
| 1, 2, 3 | 5, 5, 5 | 0.0000 | No linear tendency |
Limits
- Detects only linear relationships.
- Sensitive to outliers in either list.
- Uses sample covariance with n minus one, not population covariance.
- Magnitude depends on the units of both variables.
Common mistakes
- Entering the two lists in different orders.
- Using n instead of n minus one for a sample.
- Treating a value near zero as proof of no relationship at all.
- Including thousands separators such as 1,000 in a list.
- Comparing covariance magnitudes across different units.
Try it yourself
Quick checks. Answers sit tucked under each question.
X 1,2,3 and Y 3,2,1?
-1.0000 with 3 pairs, means 2.0000 and 2.0000.
X 10,20,30,40 and Y 5,10,15,20?
83.3333 with 4 pairs, means 25.0000 and 12.5000.
Questions
What is covariance?
A measure of the direction in which two variables move together.
What does a negative covariance mean?
Higher values of one variable tend to occur with lower values of the other.
Sample or population covariance?
This tool uses the sample form, dividing by n minus one.
How is covariance different from correlation?
Correlation rescales covariance to a value between minus one and one.
What input format is accepted?
Plain decimal numbers separated by commas, with the same count in both lists.
Can covariance be zero?
Yes, when there is no linear tendency between the paired values.