# Covariance between $$$\left\{1, 2, 3, 4, 5\right\}$$$ and $$$\left\{1, 3, 6, 5, 8\right\}$$$

Related calculator: Correlation Coefficient Calculator

### Your Input

**Find the sample covariance between $$$\left\{1, 2, 3, 4, 5\right\}$$$ and $$$\left\{1, 3, 6, 5, 8\right\}$$$.**

### Solution

The sample covariance of data is given by the formula $$$cov(x,y) = \frac{\sum_{i=1}^{n} \left(x_{i} - \mu_{x}\right)\cdot \left(y_{i} - \mu_{y}\right)}{n - 1}$$$, where $$$n$$$ is the number of values, $$$x_i, i=\overline{1..n}$$$ and $$$y_i, i=\overline{1..n}$$$ are the values themselves, $$$\mu_{x}$$$ is the mean of the x-values, and $$$\mu_{y}$$$ is the mean of the y-values.

The mean of the x-values is $$$\mu_{x} = 3$$$ (for calculating it, see mean calculator).

The mean of the y-values is $$$\mu_{y} = \frac{23}{5}$$$ (for calculating it, see mean calculator).

Since we have $$$n$$$ points, $$$n = 5$$$.

The sum of $$$\left(x_{i} - \mu_{x}\right)\cdot \left(y_{i} - \mu_{y}\right)$$$ is $$$\left(1 - 3\right)\cdot \left(1 - \frac{23}{5}\right) + \left(2 - 3\right)\cdot \left(3 - \frac{23}{5}\right) + \left(3 - 3\right)\cdot \left(6 - \frac{23}{5}\right) + \left(4 - 3\right)\cdot \left(5 - \frac{23}{5}\right) + \left(5 - 3\right)\cdot \left(8 - \frac{23}{5}\right) = 16.$$$

Thus, $$$cov(x,y) = \frac{\sum_{i=1}^{n} \left(x_{i} - \mu_{x}\right)\cdot \left(y_{i} - \mu_{y}\right)}{n - 1} = \frac{16}{4} = 4$$$.

### Answer

**The sample covariance is $$$cov(x,y) = 4$$$A.**