Covariance
Formula and examples for the covariance of a series of numbers"
Covariance is a measure of the linear relationship between two statistical variables.
The covariance can be determined as a sample covariance for a subset, or for the entire set. Different formulas apply for total quantity or sample.
Empirical covariance Formulas
To calculate the covariance of a sample
\(\displaystyle cov(x,y)=\frac{1}{n1} \left( \sum^n_{i=1} (x_i\overline{x})(x_i\overline{y}) \right) \)
Covariance
To calculate the covariance of a total quantity
\(\displaystyle cov(x,y)=\frac{1}{n} \left( \sum^n_{i=1} (x_i\overline{x})(x_i\overline{y}) \right) \)
\(n\) Number of data points \(x_i\) Single value of x \(\overline{x}\) Mean of x \(y_i\) Single value of y \(\overline{y}\) Mean of y
Example
In the example we assume that a number of carpenters make a certain number of chairs per day
3 carpenters: 10 chairs
5 carpenters: 16 chairs
7 carpenters: 22 chairs
First, the arithmetic mean is calculated from the number of workers and the number of chairs.
\(\displaystyle 3+4+7=\frac{15}{3}=\color{#44F}{5}\)
\(\displaystyle 10+16+22=\frac{48}{3}=\color{#44F}{16}\)
Calculate covariance:
\(\displaystyle cov(x,y)= ((x_1\overline{x}) · (y_1\overline{y})\) \(\displaystyle +(x_2\overline{x}) · (y_2\overline{y})\) \(\displaystyle +(x_3\overline{x}) · (y_3\overline{y})) \)
\(\displaystyle cov(x,y)= ((35) · (1016)\) \(\displaystyle +(55) · (1616)\) \(\displaystyle +(75) · (2216)) \)
\(\displaystyle = (2 · 6) +(0 ·0) +(2 · 6) \)
\(\displaystyle = 12 +0 +12 =24 \)
\(\displaystyle = \frac{24}{3}=\color{#44F}{8} \)
In the case of a sample (empirical covariance), divide by \(n1\) instead of \(n\). In the example above, divide by 2.
Calculate covariance online →
