STATISTICS CALCULATOR

Covariance Calculator

Calculate sample and population covariance from summary statistics, with the means of both variables.

Reviewed by the Calculator.nu math team
Updated August 2026
Sample covariance
19.0556
Population covariance
17.15
Mean of x
5.5

The formula

cov = (Σxy − ΣxΣy ÷ n) ÷ (n − 1)
# divide by n for the population version

How to calculate covariance

Covariance measures whether two variables move together. Positive means they tend to rise and fall in step; negative means one rises as the other falls; near zero means no consistent linear relationship.

Covariance carries the units of both variables multiplied together, which makes the raw magnitude almost impossible to interpret. Dividing by the two standard deviations turns it into a correlation coefficient, which is why correlation is usually reported instead.

Fill in the following:

  • Number of pairs
  • Sum of x
  • Sum of y
  • Sum of x × y

The result updates on every keystroke. The URL updates too, which makes the filled-in version easy to bookmark or send to someone else.

The calculation runs on exactly the numbers currently in the fields above, recomputed in full each time — there is no dependency on the order values are entered in, so adjusting one input to test a scenario and then changing it back leaves the result exactly where it started.

Why covariance matters

A covariance calculation gets used both to check work already done by hand and to explore how a formula behaves without redoing the algebra every time an input changes — this page exists for both, since the underlying arithmetic is the same either way.

It is useful for checking a manual calculation before submitting or acting on it, and equally useful for building intuition about a formula by adjusting one input at a time and watching how the result moves in response — a much faster way to understand a relationship than working through several versions of the algebra by hand.

It is worth remembering that a formula is only ever as good as the assumptions built into it, and most of the standard equations used across science and statistics carry at least one simplifying assumption — a linear approximation, an idealised gas, a normally distributed error term — that holds well in most ordinary cases and breaks down at the extremes. The result here reflects the standard formula exactly; whether that formula's assumptions are appropriate for your particular situation is a separate judgement worth making deliberately rather than assuming automatically.

It is worth keeping a note of which inputs were used to produce a given result, particularly where the figure is going into a report or a further calculation — reproducing a result later, or explaining how it was reached, is far easier with the original inputs to hand than by trying to reverse-engineer them from the output alone.

Worked example

Here is the calculation with the starting values:

  • Number of pairs: 10
  • Sum of x: 55
  • Sum of y: 125
  • Sum of x × y: 859

That gives:

  • Sample covariance: 19.0556
  • Population covariance: 17.15
  • Mean of x: 5.5

The figures above are the calculator's own default values, shown purely so the working is visible rather than hidden — the same steps apply exactly to your own numbers, entered in the fields at the top of this page.

Reading the result

Use the sign and the comparison, not the number. Covariance is genuinely useful inside other calculations — portfolio variance, regression slopes, principal component analysis — rather than as a statistic to report.

Where this goes wrong. Rescaling a variable rescales the covariance. Measuring height in centimetres rather than metres multiplies it by 100 with no change in the underlying relationship, which is exactly why correlation exists.

A result that is wrong by an exact factor of ten, a hundred or a similar round number is almost always a units error rather than a mistake in the formula itself — checking each input against the unit stated beside it is the fastest way to track it down.

Correlation is covariance divided by the product of the two standard deviations. That normalisation removes the units and confines the result to the range −1 to +1.

Because portfolio variance depends on how holdings move relative to each other in their own units. Combining assets with low or negative covariance is the mathematical basis of diversification.

It returns sample covariance. With 10 number of pairs, 55 sum of x and 125 sum of y, that comes to 19.0556. Change any field and the figure moves with it.

Generally, no more than the least precise input justifies — a result reported to six decimal places from inputs measured to two significant figures is implying a precision the calculation does not actually have. The calculator shows full precision so you can round appropriately for your own use.

Yes — the equation shown in the formula section above is the standard form used in textbooks and reference material for this calculation, not a simplified or approximate version.

Yes, in the sense that it applies the correct standard formula and returns an accurate result for the inputs given — but check your own course or publication's requirements for how results should be rounded, presented and referenced, since those conventions vary and are not something a calculator can know on your behalf.

Was this calculator helpful?

Tap a star to rate it. Your feedback helps us improve the tools people rely on most.