Covariance Calculator

Enter your x and y values to see how they vary together.

Numbers separated by commas, spaces or new lines.

One y for each x, in the same order.

Try

Result

You enteredx={1, 2, 3, 4, 5}y={2, 4, 5, 4, 5}x = \left\{ 1,\ 2,\ 3,\ 4,\ 5 \right\} \quad y = \left\{ 2,\ 4,\ 5,\ 4,\ 5 \right\}

Sample covariance 1.5, population covariance 1.2\displaystyle \text{Sample covariance } 1.5,\ \text{population covariance } 1.2

Mean of x

3\displaystyle 3

Mean of y

4\displaystyle 4
Show the work
  1. Means of x and y

    Covariance measures how x and y move together around their means, so find the means first. There are n=5n = 5 pairs.

    xˉ=3yˉ=4\begin{gathered} \bar{x} = 3 \\ \bar{y} = 4 \end{gathered}
  2. Sum of products of deviations

    Each pair contributes the product of its two deviations: positive when both are above or both below their means, negative when one is above and the other below.

    Sxy=∑(x−xˉ)(y−yˉ)=(1−3)(2−4)+(2−3)(4−4)+(3−3)(5−4)+(4−3)(4−4)+(5−3)(5−4)=6\begin{aligned} S_{xy} &= \sum \left(x - \bar{x}\right)\left(y - \bar{y}\right) \\ &= \left(1 - 3\right)\left(2 - 4\right) + \left(2 - 3\right)\left(4 - 4\right) + \left(3 - 3\right)\left(5 - 4\right) + \left(4 - 3\right)\left(4 - 4\right) + \left(5 - 3\right)\left(5 - 4\right) \\ &= 6 \end{aligned}
  3. Covariance

    Divide by n−1n - 1 when the pairs are a sample, and by nn when they are the whole population.

    Using sxy=Sxyn−1,σxy=Sxyns_{xy} = \frac{S_{xy}}{n - 1},\quad \sigma_{xy} = \frac{S_{xy}}{n}

    sxy=64=1.5σxy=65=1.2\begin{gathered} s_{xy} = \frac{6}{4} = 1.5 \\ \sigma_{xy} = \frac{6}{5} = 1.2 \end{gathered}
  4. Result

    So the sample covariance is 1.51.5 and the population covariance is 1.21.2.

Worked examples