Covariance

Covariance provides a measure of the strength of the correlation between two random variables.

Suppose X and Y are random variables with means E(X) and E(Y), and standard deviations sd(X) and sd(Y), respectively. The covariance of X and Y is defined by

cov(X, Y) = E([X - E(X)][Y - E(Y)])
or
cov(X, Y) = E(XY) - E(X)E(Y)

Example

What is the covariance of the data set X = (1, 2, 4, 6, 7) and Y = (2, 3, 4, 7, 9)?

X Y X-E(X) Y-E(Y) [X-E(X)][Y-E(Y)]
12-3-39
23-2-24
440-10
67224
793412
sum202529
E455.8
E: expected value or mean

or

X Y XY
122
236
4416
6742
7963
sum2025129
E4525.8
E: expected value or mean

From the table above,

cov(X, Y) = E(XY) - E(X)E(Y)
= 25.8 - (4)(5)
= 5.8