# Covariance

#### statsrocks

##### New Member
Hi, i've got an exam wednesday and i was just going through some stuff when i came across this question. Could anybody tell me how to do it?

Suppose that X is a random variable with mean 7 and variance 4, and let Y be a random variable independent of X, with mean 0 and variance 1. Let Z=X-Y. Evaluate Cov(X,Z) and hence p(X,Z).

It looks staightforward enough but im not too great at stats so i dont know really where to start..
Any help is appreciated!

#### Dragan

##### Super Moderator
Hi, i've got an exam wednesday and i was just going through some stuff when i came across this question. Could anybody tell me how to do it?

Suppose that X is a random variable with mean 7 and variance 4, and let Y be a random variable independent of X, with mean 0 and variance 1. Let Z=X-Y. Evaluate Cov(X,Z) and hence p(X,Z).

It looks staightforward enough but im not too great at stats so i dont know really where to start..
Any help is appreciated!
Try using;

E[x]=7; E[y]=0; Var[x]=4; Var[y]=1, then

z=x-y

so E[z]=E[x]-E[y]=7-0=7,

Var[z]=Var[x]+Var[y]= 4 +1 =5. (Variance Sum Law for independent var's)

Next,

Cov[x,z]=Cov[x,x-y]=E[x*(x - y)] - E[x]*E[x-y] = E[x^2] - E[xy] - E[x]*E[x-y]

Thus, we have: Cov[x,z] = 4 = 53 - 49, since E[x]=E[x-y]=7 and E[x^2]=53 because we must have Var[x]=E[x^2] - (E[x])^2, and E[xy]=0 because x and y are independent.

Note: E[x^2]=Var[x] + (E[x])^2 = 4 + 49 = 53.

And, so, the correlation Corr[x,z] = Cov[x,z]/(Sqrt(Var[x])*Sqrt(Var[z])) = 4/(Sqrt[4]*Sqrt[5]) = 2/Sqrt(5) = 0.894...

How's that?

Last edited:

#### statsrocks

##### New Member
Thats great! Thanks very much!