Expectation, Covariance and Correlation
In this section, we study further properties of expectations of random variables. We move on from the expectation of a single random variable to consider the expectation of the function of a collection of random variables, X1,X2,…,Xn. We pay particular attention to the expectation of functions of two random variables X and Y, say. We define the covariance as a measure of how the random variables X and Y vary together and the correlation which provides a measure of linear dependence between two random variables X and Y.
Expectation of a function of random variables
If X1,X2,…,Xn are jointly continuous, then the expectation of the function g(X1,X2,…,Xn) is given by
E[g(X1,…,Xn)]=∫⋯∫Rng(x1,…,xn)fX1,…,Xn(x1,…,xn)dx1⋯dxn
Note that if X1,X2,…,Xn are discrete, we replace the integrals by summations and the joint p.d.f. with the joint p.m.f.
Expectation has the following important properties:
- The expectation of a sum is equal to the sum of the expectations (see Section 5.3):
E[n∑i=1Xi]=n∑i=1E[Xi];
- If X and Y are independent, then
E[XY]=E[X]E[Y];
- If X and Y are independent and g and h are any real functions, then
E[g(X)h(Y)]=E[g(X)]E[h(Y)].
Covariance
Covariance
The
covariance of two random variables,
X and
Y, is defined by
Cov(X,Y)=E[(X−E[X])(Y−E[Y])]
Covariance has the following important properties:
- Covariance is equal to the expected value of the product minus the product of the expected values.
Cov(X,Y)=E[XY]−E[X]E[Y].
- If X and Y are independent, then cov(X,Y) = 0. The converse is NOT true.
- The covariance of two equal random variables is equal to the variance of that random variable.
Cov(X,X)=Var(X).
- The covariance of a scalar multiple of a random variable (in either argument) is equal to the scalar multiple of the covariance. Additionally covariance is invariant under the addition of a constant in either argument.
Cov(aX+b,cY+d)=acCov(X,Y).
- The covariance of a linear combination of random variables is equal to a linear combination of the covariances.
Cov(m∑i=1aiXi,n∑j=1bjYj)=m∑i=1n∑j=1aibjCov(Xi,Yj).
- There is a further relationship between variance and covariance:
Var(X+Y)=Var(X)+Var(Y)+2Cov(X,Y).
- More generally this relationship between variance and covariance becomes:
Var(n∑i=1aiXi)=n∑i=1a2iVar(Xi)+2∑1≤i<j≤naiajCov(Xi,Xj).
- Consider the above identity if X1,X2,…,Xn are independent, and each ai is equal to 1 (see Section 5.3). Then we have:
Var(n∑i=1Xi)=n∑i=1Var(Xi).
Density on a circle
Suppose that
X and
Y have joint probability density function
fX,Y(x,y)={1πx2+y2≤10otherwise.
Then Cov(X,Y)=0 but X and Y are not independent.
Watch Video 21 for an explanation of Example 13.2.2: Density on a circle or see the written explanation below.
Video 21: Density on a circle
Explanation - Example 13.2.2: Density on a circle.
We begin by computing E[X], E[Y] and E[XY].
To compute E[X], we first find fX(x).
Note that if X=x, then
x2+y2≤1⇔y2≤1−x2⇔−√1−x2≤y≤√1−x2.
Hence, for −1<x<1,
fX(x)=∫√1−x2−√1−x2fX,Y(x,y)dy=∫√1−x2−√1−x21πdy=[yπ]√1−x2−√1−x2=√1−x2π−−√1−x2π=2√1−x2π.
Thus
fX(x)={2√1−x2π−1<x<10otherwise.
see Figure 13.2.
Therefore E[X] is given by
E[X]=∫∞−∞xfX(x)dx=∫1−1x2√1−x2πdx=∫0−1x2√1−x2πdx+∫10x2√1−x2πdx
Using a change of variable v=−x in the first integral:
∫0−1x2√1−x2πdx=∫01(−v)2√1−(−v)2π(−dv)=−∫10v2√1−(v)2πdv.
Hence, the red and blue integrals below are equal:
E[X]=−∫10v2√1−v2πdv+∫10x2√1−x2πdx=0.
A symmetry argument gives that
fY(y)={2√1−y2π−1<y<10otherwise,
and E[Y]=0.
Now
E[XY]=∫∫x2+y2≤1xy1πdydx=∫1−1∫√1−x2−√1−x2xy1πdydx=∫1−1xπ[y22]√1−x2−√1−x2dx=∫1−1x2π[1−x2−(1−x2)]dx=∫1−1x2π(0)dx=0.
Therefore
cov(X,Y)=E[XY]−E[X]E[Y]=0−0×0=0.
However, X and Y are not independent.
Note that for x=0.8 and y=0.8, x2+y2=0.82+0.82=1.28>1, so
fX,Y(0.8,0.8)=0.
However, fX(0.8)=2π√1−0.82=0.382 and also fY(0.8)=0.382 giving
fX(0.8)fY(0.8)=0.382×0.382≠0=fX,Y(0.8,0.8).
Correlation
Correlation
If
Var(X)>0 and
Var(Y)>0, then the
correlation of
X and
Y is defined by
ρ(X,Y)=Cov(X,Y)√Var(X)Var(Y).
Correlation has the following important properties:
- −1≤ρ(X,Y)≤1.
- If X and Y are independent, then ρ(X,Y)=0. Note, again, that the converse is not true.
- Correlation is invariant under a scalar multiple of a random variable (in either argument) up to a change of sign. Additionally correlation is invariant under the addition of a constant in either argument.
ρ(aX+b,cY+d)={ρ(X,Y),if ac>0,−ρ(X,Y),if ac<0.
For example, the correlation between height and weight of individuals will not be effected by the choice of units of measurement for height (cm, mm, feet) and weight (kg, pounds, grammes) but the covariance (and variance) will change depending upon the choice of units.
Student Exercises
Attempt the exercises below.
Show that if X and Y are two independent random variables then Cov(X,Y)=0.
Solution to Exercise 13.1.
If X and Y are independent, then E[XY]=E[X]E[Y], and therefore
Cov(X,Y)=E[XY]−E[X]E[Y]=E[X]E[Y]−E[X]E[Y]=0.
Assume that X and Y are two random variables with Var(X)=Var(Y)=11144 and Cov(X,Y)=−1144. Find the variance of 12X+Y.
Solution to Exercise 13.2.
Var(12X+Y)=Var(14X)+Var(Y)+2Cov(12X,Y)=14Var(X)+Var(Y)+Cov(X,Y)=1411144+11144−1144=51576