Sales Toll Free No: 1-855-666-7446

# Covariance Calculator

Top
Covariance calculator helps to measure how two random variables are related together. Covariance calculator first finds the mean and then determines the covariance.

## Steps

Step 1 : First find the mean of X and Y.

Step 2 : Substitute these values into the covariance formula given below.

Cov (X, Y) = $\frac{\Sigma (x_i - \bar{x})(y_i - \bar{y})}{N}$

where,
$x_i$ = values of X
$y_i$ = values of Y
$\bar{x}$ = mean value of X
$\bar{y}$ = mean value of Y
N = number of observation

## Problems

Below are some of the problems based on covariance.

### Solved Examples

Question 1:
Find the covariance of the following set of data,
X = 3, 5, 7, 1, 9
Y = 4, 6, 8, 6, 5

Solution:
Step 1 : Given,
X = 3, 5, 7, 1, 9
Y = 4, 6, 8, 6, 5
N = 5

Mean of X ($\bar{x}$) = $\frac{3 + 5 + 7 + 1 + 9}{5}$ = $\frac{25}{5}$ = 5
$\bar{x}$ = 5

Mean of Y ($\bar{y}$) = $\frac{4 + 6 + 8 + 6 + 5}{5}$ = $\frac{29}{5}$ = 5.8
$\bar{y}$ = 5.8

$x_1 - \bar{x}$ = 3 - 5 = -2
$x_2 - \bar{x}$ = 5 - 5 = 0
$x_3 - \bar{x}$ = 7 - 5 = 2
$x_4 - \bar{x}$ = 1 - 5 = -4
$x_5 - \bar{x}$ = 9 - 5 = 4

$y_1 - \bar{y}$ = 4 - 5.8 = -1.8
$y_2 - \bar{y}$    = 6 - 5.8 = 0.2
$y_3 - \bar{y}$ = 8 - 5.8 = 2.2
$y_4 - \bar{y}$ = 6 - 5.8 = 2.2
$y_5 - \bar{y}$ = 5 - 5.8 = -0.8

Step 2 :  Using the Covariance formula,
Cov(X, Y) = $\frac{\sum_{i}^{n} (x_i - \bar{x})(y_i - \bar{y})}{N}$

= $\frac{(-2 \times -1.8)+(0 \times 0.2)+(2 \times 2.2)+(-4 \times 2.2)+(4 \times -0.8)}{5}$

= $\frac{0.4016}{5}$
= 0.8

Covariance of X and Y is 0.8.

Question 2:
Find the covariance of the following set of data,

X = 10, 45, 30, 15
Y = 20, 35, 40, 10

Solution:
Step 1 : Given,
X = 10, 45, 30, 15
Y = 20, 35, 40, 10
N = 4

Mean of X ($\bar{x}$) = $\frac{10 + 45 + 30 + 15}{4}$ = $\frac{100}{4}$ = 25

$\bar{x}$ = 25

Mean of Y ($\bar{y}$) = $\frac{20 + 35 + 40 + 10}{4}$ = $\frac{105}{4}$ = 26.25

$\bar{y}$ = 26.25

$x_1 - \bar{x}$ = 10 - 25 = -15
$x_2 - \bar{x}$ = 45 - 25 = 20
$x_3 - \bar{x}$ = 30 - 25 = 5
$x_4 - \bar{x}$ = 15 - 25 = -10

$y_1 - \bar{y}$ = 20 - 26.25 = -6.25
$y_2 - \bar{y}$ = 35 - 26.25 = 8.75
$y_3 - \bar{y}$ = 40 - 26.25 = 13.75
$y_4 - \bar{y}$ = 10 - 26.25 = -16.25

Step 2 :  Using the Covariance formula,
Cov(X, Y) = $\frac{\sum_{i}^{n} (x_i - \bar{x})(y_i - \bar{y})}{N}$

= $\frac{(-15 \times -6.25)+(20 \times 8.75)+(5 \times 13.75)+(-10 \times -16.25)}{4}$

= $\frac{98.75+175+68.75+162.5}{4}$

= 126

Covariance of X and Y is 126.