Search the complete library

What do you want to learn or calculate?

Quick linksAll calculatorsMath subjectsPractice questionsFormula library
← Statistics formulas

Sample covariance

Measure how two quantitative variables vary together.

Statistics · Association
$$s_{xy}=\frac{\sum(x_i-\bar x)(y_i-\bar y)}{n-1}$$

Sample covariance is one of 2 association formulas in the statistics section of this library, and it is used at ap · university level.

Why sample covariance works

When both variables sit above their own means, or both sit below, the two deviations share a sign and their product is positive. When one is high while the other is low, the product is negative. Adding those products measures which pattern dominates, and the n minus 1 matches the sample variance correction.

What each symbol means

Paired values are $(x_i,y_i)$.

Sample covariance: when it holds

$n>1$; covariance depends on measurement units.

When it stops applying

It only detects straight-line co-movement. For x values -2, -1, 0, 1, 2 paired with their squares, the covariance is exactly 0 even though y is completely determined by x, because the rising half and the falling half cancel out.

Sample covariance: a worked example

Positive covariance means larger $x$ values tend to occur with larger $y$ values.

The mistake to avoid

What people do: Comparing covariances from different data sets to judge which relationship is stronger.

Why it goes wrong: Covariance carries the units of both variables multiplied together. Recording the same heights in centimetres instead of metres multiplies the covariance by 100 without changing the relationship one bit.

Do this instead: Standardise before comparing: divide by both standard deviations to get the correlation, which has no units and a fixed scale.

Sample covariance: step by step

  1. Name the unknown, and the unit the answer has to come out in.
  2. Match the symbols to your values. Paired values are $(x_i,y_i)$.
  3. Check the conditions before substituting. $n>1$; covariance depends on measurement units.
  4. Substitute, keep exact values to the last line, then test the sign, size, and unit against a rough estimate — the check that catches most statistics slips.

Where this formula fits

Subject
Statistics formulas — 21 entries in this library
Topic
Association
Level
AP · University

Formulas are easiest to keep when they sit inside a method rather than on a list. Use the links below to see where sample covariance comes from, to check a calculation against a tool, and to practise it until you can recall it without looking.

Questions about sample covariance

What counts as a large covariance?

There is no answer, because the size depends entirely on the units. Only the sign is interpretable on its own, which is why correlation exists as the standardised version.

What is the covariance of a variable with itself?

It is the variance. Both deviations become the same number, so each product is a square, and the formula collapses into the sample variance formula exactly.

Why divide by n minus 1 here as well?

For the same reason as in the variance: two means were estimated from the same data, so dividing by n would bias the result toward zero. The correction restores an unbiased estimate.

Does zero covariance prove the two variables are independent?

No. The squared example above has zero covariance and a perfect relationship. Zero covariance only rules out a linear trend, not any relationship at all.

Stuck on a problem?

Work a sample covariance problem step by step

Type your own problem, or upload a photo of it. You get the method, the answer, and a check you can repeat yourself.