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,,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.

13.1 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)dx1dxn

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[i=1nXi]=i=1nE[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)].

13.2 Covariance

Covariance

The covariance of two random variables, X and Y, is defined by
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].
  • 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(i=1maiXi,j=1nbjYj)=i=1mj=1naibjCov(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(i=1naiXi)=i=1nai2Var(Xi)+21i<jnaiajCov(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(i=1nXi)=i=1nVar(Xi).

Density on a circle

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

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

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

Figure 13.1: Example: Point at (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[Y] and E[XY].
To compute E[X], we first find fX(x).
Note that if X=x, then
x2+y21y21x21x2y1x2.
Hence, for 1<x<1,
fX(x)=1x21x2fX,Y(x,y)dy=1x21x21πdy=[yπ]1x21x2=1x2π1x2π=21x2π.
Thus
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 X.

Therefore E[X] is given by
E[X]=xfX(x)dx=11x21x2πdx=10x21x2πdx+01x21x2πdx
Using a change of variable v=x in the first integral:
10x21x2πdx=10(v)21(v)2π(dv)=01v21(v)2πdv.
Hence, the red and blue integrals below are equal:
E[X]=01v21v2πdv+01x21x2πdx=0.
A symmetry argument gives that
fY(y)={21y2π1<y<10otherwise,
and E[Y]=0.
Now
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.
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π10.82=0.382 and also fY(0.8)=0.382 giving
fX(0.8)fY(0.8)=0.382×0.3820=fX,Y(0.8,0.8).


13.3 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.


Task: Session 7

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


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+111441144=51576