Chapter 13 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,,XnX1,X2,,Xn. We pay particular attention to the expectation of functions of two random variables XX and YY, say. We define the covariance as a measure of how the random variables XX and YY vary together and the correlation which provides a measure of linear dependence between two random variables XX and YY.

13.1 Expectation of a function of random variables


If X1,X2,,XnX1,X2,,Xn are jointly continuous, then the expectation of the function g(X1,X2,,Xn)g(X1,X2,,Xn) is given by
E[g(X1,,Xn)]=Rng(x1,,xn)fX1,,Xn(x1,,xn)dx1dxnE[g(X1,,Xn)]=Rng(x1,,xn)fX1,,Xn(x1,,xn)dx1dxn

Note that if X1,X2,,XnX1,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[ni=1Xi]=ni=1E[Xi];E[ni=1Xi]=ni=1E[Xi];
  • If XX and YY are independent, then
    E[XY]=E[X]E[Y];E[XY]=E[X]E[Y];
  • If XX and YY are independent and gg and hh are any real functions, then
    E[g(X)h(Y)]=E[g(X)]E[h(Y)].E[g(X)h(Y)]=E[g(X)]E[h(Y)].

13.2 Covariance

Covariance

The covariance of two random variables, XX and YY, is defined by
Cov(X,Y)=E[(XE[X])(YE[Y])]Cov(X,Y)=E[(XE[X])(YE[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].Cov(X,Y)=E[XY]E[X]E[Y].
  • If XX and YY are independent, then cov(X,Y)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).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).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(mi=1aiXi,nj=1bjYj)=mi=1nj=1aibjCov(Xi,Yj).Cov(mi=1aiXi,nj=1bjYj)=mi=1nj=1aibjCov(Xi,Yj).
  • There is a further relationship between variance and covariance:
    Var(X+Y)=Var(X)+Var(Y)+2Cov(X,Y).Var(X+Y)=Var(X)+Var(Y)+2Cov(X,Y).
  • More generally this relationship between variance and covariance becomes:
    Var(ni=1aiXi)=ni=1a2iVar(Xi)+21i<jnaiajCov(Xi,Xj).Var(ni=1aiXi)=ni=1a2iVar(Xi)+21i<jnaiajCov(Xi,Xj).
  • Consider the above identity if X1,X2,,XnX1,X2,,Xn are independent, and each aiai is equal to 11 (see Section 5.3). Then we have:
    Var(ni=1Xi)=ni=1Var(Xi).Var(ni=1Xi)=ni=1Var(Xi).

Density on a circle

Suppose that XX and YY have joint probability density function
fX,Y(x,y)={1πx2+y210otherwise.fX,Y(x,y)={1πx2+y210otherwise.

Then Cov(X,Y)=0Cov(X,Y)=0 but XX and YY are not independent.

 Example: Point at $(x,y) =(-0.25,0.15)$.

Figure 13.1: Example: Point at (x,y)=(0.25,0.15)(x,y)=(0.25,0.15).

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[X], E[Y]E[Y] and E[XY]E[XY].
To compute E[X]E[X], we first find fX(x)fX(x).
Note that if X=xX=x, then
x2+y21y21x21x2y1x2.x2+y21y21x21x2y1x2.
Hence, for 1<x<11<x<1,
fX(x)=1x21x2fX,Y(x,y)dy=1x21x21πdy=[yπ]1x21x2=1x2π1x2π=21x2π.fX(x)=1x21x2fX,Y(x,y)dy=1x21x21πdy=[yπ]1x21x2=1x2π1x2π=21x2π.
Thus
fX(x)={21x2π1<x<10otherwise.fX(x)={21x2π1<x<10otherwise.
see Figure 13.2.
Plot of the p.d.f. of $X$.

Figure 13.2: Plot of the p.d.f. of XX.

Therefore E[X]E[X] is given by
E[X]=xfX(x)dx=11x21x2πdx=01x21x2πdx+10x21x2πdxE[X]=xfX(x)dx=11x21x2πdx=01x21x2πdx+10x21x2πdx
Using a change of variable v=xv=x in the first integral:
01x21x2πdx=01(v)21(v)2π(dv)=10v21(v)2πdv.01x21x2πdx=01(v)21(v)2π(dv)=10v21(v)2πdv.
Hence, the red and blue integrals below are equal:
E[X]=10v21v2πdv+10x21x2πdx=0.E[X]=10v21v2πdv+10x21x2πdx=0.
A symmetry argument gives that
fY(y)={21y2π1<y<10otherwise,fY(y)={21y2π1<y<10otherwise,
and E[Y]=0E[Y]=0.
Now
E[XY]=x2+y21xy1πdydx=111x21x2xy1πdydx=11xπ[y22]1x21x2dx=11x2π[1x2(1x2)]dx=11x2π(0)dx=0.E[XY]=x2+y21xy1πdydx=111x21x2xy1πdydx=11xπ[y22]1x21x2dx=11x2π[1x2(1x2)]dx=11x2π(0)dx=0.
Therefore
cov(X,Y)=E[XY]E[X]E[Y]=00×0=0.cov(X,Y)=E[XY]E[X]E[Y]=00×0=0.
However, XX and YY are not independent.
Note that for x=0.8x=0.8 and y=0.8y=0.8, x2+y2=0.82+0.82=1.28>1x2+y2=0.82+0.82=1.28>1, so
fX,Y(0.8,0.8)=0.fX,Y(0.8,0.8)=0.
However, fX(0.8)=2π10.82=0.382fX(0.8)=2π10.82=0.382 and also fY(0.8)=0.382fY(0.8)=0.382 giving
fX(0.8)fY(0.8)=0.382×0.3820=fX,Y(0.8,0.8).fX(0.8)fY(0.8)=0.382×0.3820=fX,Y(0.8,0.8).


13.3 Correlation

Correlation

If Var(X)>0Var(X)>0 and Var(Y)>0Var(Y)>0, then the correlation of XX and YY is defined by
ρ(X,Y)=Cov(X,Y)Var(X)Var(Y).ρ(X,Y)=Cov(X,Y)Var(X)Var(Y).

Correlation has the following important properties:

  • 1ρ(X,Y)11ρ(X,Y)1.
  • If XX and YY are independent, then ρ(X,Y)=0ρ(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.ρ(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.


Task: Session 7

Attempt the R Markdown file for Session 7:
Session 7: Joint distributions


Student Exercises

Attempt the exercises below.


Show that if XX and YY are two independent random variables then Cov(X,Y)=0Cov(X,Y)=0.

Solution to Exercise 13.1.
If XX and YY are independent, then E[XY]=E[X]E[Y]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.Cov(X,Y)=E[XY]E[X]E[Y]=E[X]E[Y]E[X]E[Y]=0.



Assume that XX and YY are two random variables with Var(X)=Var(Y)=11144Var(X)=Var(Y)=11144 and Cov(X,Y)=1144Cov(X,Y)=1144. Find the variance of 12X+Y12X+Y.

Solution to Exercise 13.2.
Var(12X+Y)=Var(14X)+Var(Y)+2Cov(12X,Y)=14Var(X)+Var(Y)+Cov(X,Y)=1411144+111441144=51576Var(12X+Y)=Var(14X)+Var(Y)+2Cov(12X,Y)=14Var(X)+Var(Y)+Cov(X,Y)=1411144+111441144=51576