# Covariance Examples

Covariance of two vectors $X$ and $y$ gives the relation between them, that is, how much the vectors point in the same direction.
$cov(X,Y)$ = $\frac{\sum_{i=1}^{n}(x_i-\bar{x})(y_i-\bar{y})}{N-1}$
When a distribution table is given with the frequency of each data, the covariance is given by the given formula,
$cov(X,Y)$ = $\frac{\sum f_ix_iy_i}{N}$ $-\bar{x}\bar{y}$

## Word Problems

Problem 1:

Find the covariance between the given two sets of data.

$X:\ 2,\ 5,\ 8,\ 11$

$Y:\ 5,\ 9,\ 1,\ 4$

Solution:

The mean of both the vectors can be given as,

$\bar{x}$ = $6.5$

$\bar{y}$ = $4.75$

The covariance can be calculated by using the formula,

$cov(X,Y)$ = $\frac{\sum_{i=1}^{n}(x_i-\bar{x})(y_i-\bar{y})}{N-1}$

Putting the values and calculating we get,

$cov(X,Y)$ = $\frac{(2-6.5)+(5-6.5)+(8-6.5)+(11-6.5))((5-4.75)+(9-4.75)+(1-4.75)+(4-4.75))}{4-1}$ = $-5.5$
Problem 2:

The given table shows the profit of two companies (in million dollars) per annum. Find the covariance between them.

 Year Ageis Technologies Ajanata Technologies 2005 11 9 2006 8 4 2007 7 12 2008 9 11

Solution:

The mean of both the data set is given as,

Mean for Ageis technologies, $\bar{x}$ = $8.75$

Mean for Ajanata technologies, $\bar{y}$ = $9$

Total number of observations, $N$ = $4$

The covariance can be calculated by using the formula,

$cov(X,Y)$ = $\frac{\sum_{i=1}^{n}(x_i-\bar{x})(y_i-\bar{y})}{N-1}$

Putting the values and calculating we get,

$cov(X,Y)$ = $\frac{(11-8.75)+(8-8.75)+(8-8.75)+(7-8.75))((9-9)+(4-9)+(12-9)+(11-9))}{4-1}$ = -$0.333$
Problem 3:

The marks of $6$ students of a class for Mathematics and English is given here. Find the covariance between them.

 English 65 76 61 86 88 70 Mathematics 72 67 56 94 81 98

Solution:

The mean of both the data set is given as,

English, $\bar{x}$ = $74.33$

Mathematics, $\bar{y}$ = $78$

Total number of observations, $N$ = $6$

The covariance can be calculated by using the formula,

$cov(X,Y)$ = $\frac{\sum_{i=1}^{n}(x_i-\bar{x})(y_i-\bar{y})}{N-1}$

Putting the values and calculating we get,

$cov(X,Y)$ = $94.4$