# Covariance

#### oli4

##### New Member
I have a problem with a contingency table for X=1, 2, 3 and Y = 1 and 2.

In a related question, the correlation is asked for X and Y. As far as I know, the correlation needs the covariance in the
nominator. Unfortunately, i am unable to apply the formulae for the covariance. How did you calculate this covariance?

Best regards,
Olivier

#### oli4

##### New Member
ps: the contintency table looks like this:

X = 1 X = 2 X = 3
Y=1 0.1 0.3 0.1
Y=2 0.2 0.2 0.1

I hope, I dit not miss a thread that already treated this topic....

#### BGM

##### TS Contributor
Hint: $$Cov[X, Y] = E[XY] - E[X]E[Y]$$

#### oli4

##### New Member
Thx... I've already found the formula.

My specific problem is: how to calculate the part E[XY]. What is meant by this part of the formula?

The rest (E[X]E[Y]) I consider quite easy (mean of Y by the mean of X)...

I know I appear to be a bit dumb - but unfortunately I have really no idea (and I did not find anything in this forum in this regard). Therefore I would really appreciate your help.

#### Dason

XY is the random variable that corresponds with the product of X and Y. So XY = 1*1 = 1 occurs with probability 0.1, XY = 1*2 = 2*1 = 2 occurs with probability 0.3 + 0.2, so on and so forth. Find the expected value of this.

#### oli4

##### New Member
so for

X = 1 X = 2 X = 3
Y=1 0.1 0.3 0.1
Y=2 0.2 0.2 0.1

+ 1*1 * 0.1 = 0.1 +
+ 1*2 * 0.3 = 0.6 +
+ 1*3 * 0.1 = 0.3 +
+ 2*1 * 0.2 = 0.4 +
+ 2*2 * 0.2 = 0.8 +
+ 2*3 * 0.1 = 0.6 = 2.8
- E[Y]*E[X] = -1.5*1.9 = 2.85
= -0.05 would be the right answer?

#### oli4

##### New Member
many thanks for your "covariance for dummies" lesson!!!