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}y={2, 4, 6}x = \left\{ 1,\ 2,\ 3 \right\} \quad y = \left\{ 2,\ 4,\ 6 \right\}

Sample covariance 2, population covariance 1.333333\displaystyle \text{Sample covariance } 2,\ \text{population covariance } 1.333333

Fraction

43\displaystyle \frac{4}{3}

Mean of x

2\displaystyle 2

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=3n = 3 pairs.

    xˉ=2yˉ=4\begin{gathered} \bar{x} = 2 \\ \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−2)(2−4)+(2−2)(4−4)+(3−2)(6−4)=4\begin{aligned} S_{xy} &= \sum \left(x - \bar{x}\right)\left(y - \bar{y}\right) \\ &= \left(1 - 2\right)\left(2 - 4\right) + \left(2 - 2\right)\left(4 - 4\right) + \left(3 - 2\right)\left(6 - 4\right) \\ &= 4 \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=42=2σxy=43≈1.333333\begin{gathered} s_{xy} = \frac{4}{2} = 2 \\ \sigma_{xy} = \frac{4}{3} \approx 1.333333 \end{gathered}
  4. Result

    So the sample covariance is 22 and the population covariance is 43≈1.333333\frac{4}{3} \approx 1.333333.

Worked examples