CalcPath
ProgressProblem setsFeedback
← Question sheet

Probability · Solutions

Expectation, Covariance and Conditional Expectation

12 questions · about 108 minutes

Work this sheet on paper, showing every step — the solutions are written as full methods so you can check your route, not just your final number. Name every result you use (“by bilinearity of covariance”, “by the tower property”, “by Jensen’s inequality”), check its hypotheses, and keep the distinction between the number E[X∣Y=y] and the random variable E[X∣Y] explicit in your writing. No calculator is needed: every answer is an exact fraction or a closed form. Full worked solutions are on a separate page, with a per-question reveal so you can check one answer without seeing the rest.

  1. 1.Computation

    The pair (X,Y) has the joint pmf

    Y=0Y=1​X=081​81​​X=141​81​​X=2083​​​

    1. (a)Find the marginal pmf of X, the marginal pmf of Y, and E[X] and E[Y].
    2. (b)Compute Cov(X,Y) from the computational formula. Then confirm its sign by deciding which cells of the table contribute positively to E[(X−μX​)(Y−μY​)] and which negatively, and by adding up those weighted contributions.
    3. (c)Compute Var(X+Y) and Var(X−Y) without finding the distribution of either variable. Then find the pmf of X−Y directly from the table and verify your value of Var(X−Y).
    4. (d)Without any further computation, write down Cov(2X+1,3−Y), naming the property you use.

    Solution

    (a) Marginals by summing the table. Column sums give the pmf of X: P(X=0)=81​+81​=41​, P(X=1)=41​+81​=83​, P(X=2)=0+83​=83​. Row sums give the pmf of Y: P(Y=0)=81​+41​+0=83​ and P(Y=1)=81​+81​+83​=85​. Hence

    E[X]=0⋅41​+1⋅83​+2⋅83​=89​,E[Y]=85​.

    (b) Computational formula. Only cells with both coordinates nonzero contribute to E[XY]: the cell (1,1) gives 1⋅81​ and the cell (2,1) gives 2⋅83​, so E[XY]=81​+86​=87​. By the computational formula for the covariance,

    Cov(X,Y)=E[XY]−E[X]E[Y]=87​−89​⋅85​=6456​−6445​=6411​.

    For the sign check, the deviations are X−89​∈{−89​,−81​,87​} and Y−85​∈{−85​,83​}. In the cells (0,0), (1,0) and (2,1) the two deviations have the same sign, so those cells push the covariance up; in (0,1) and (1,1) they have opposite signs and push it down; the cell (2,0) has probability zero and contributes nothing. Weighting each product of deviations by its cell probability,

    81​⋅6445​+41​⋅645​+83​⋅6421​−81​⋅6427​−81​⋅643​=51245+10+63−27−3​=51288​=6411​,

    the same number from the definition. It is positive because the two heaviest cells, (2,1) and (1,0) together with (0,0), all sit in the agreeing quadrants.

    (c) Variance of a sum, no hypotheses. E[X2]=1⋅83​+4⋅83​=815​, so Var(X)=815​−6481​=64120−81​=6439​. Y is Bernoulli with p=85​, so Var(Y)=85​⋅83​=6415​. By the theorem on the variance of a sum, which needs no independence,

    Var(X+Y)=6439​+6415​+2⋅6411​=6476​=1619​,Var(X−Y)=6439​+6415​−2⋅6411​=6432​=21​.

    Direct check: reading X−Y off each cell, it equals −1 on (0,1) [probability 81​], 0 on (0,0) and (1,1) [probability 81​+81​=41​], and 1 on (1,0) and (2,1) [probability 41​+83​=85​]. So E[X−Y]=−81​+85​=21​, which agrees with 89​−85​, and E[(X−Y)2]=81​+85​=43​, giving Var(X−Y)=43​−41​=21​. ✓

    (d) Bilinearity. By the theorem on bilinearity and symmetry of covariance, additive shifts are invisible and scale factors come out of each slot: Cov(2X+1,3−Y)=2⋅(−1)⋅Cov(X,Y)=−3211​.

  2. 2.Proof

    Throughout, every variable has finite variance. You may use only the definition of covariance, the theorem on bilinearity and symmetry of covariance, the identity Cov(X,X)=Var(X), and the variance-of-a-sum theorem. Independence is never assumed unless stated.

    1. (a)Prove that Cov(X+Y,X−Y)=Var(X)−Var(Y). Deduce that if X and Y have the same variance then X+Y and X−Y are uncorrelated, whether or not X and Y are independent.
    2. (b)Let X1​,…,Xn​ be pairwise uncorrelated, each with variance σ2, and let Xˉ=n1​∑i=1n​Xi​. Prove that Cov(Xi​,Xˉ)=σ2/n for every i, and that Var(Xˉ)=σ2/n.
    3. (c)Deduce that each residual Xi​−Xˉ is uncorrelated with Xˉ, and compute Var(Xi​−Xˉ).

    Solution

    (a) Expand by bilinearity. Linearity in the first slot, then in the second, gives

    Cov(X+Y,X−Y)=Cov(X,X)−Cov(X,Y)+Cov(Y,X)−Cov(Y,Y).

    By symmetry Cov(Y,X)=Cov(X,Y), so the two middle terms cancel, and the outer terms are Var(X) and Var(Y) because variance is a self-covariance. Hence Cov(X+Y,X−Y)=Var(X)−Var(Y). ■

    If Var(X)=Var(Y) the right-hand side is 0, which is the definition of X+Y and X−Y being uncorrelated. Nothing in the argument mentioned Cov(X,Y) itself — it cancelled — so the conclusion holds however strongly X and Y are related. (Uncorrelated is not the same as independent: for X, Y independent with equal variances, X+Y and X−Y are uncorrelated but ∣X−Y∣ and X+Y are typically dependent.)

    (b) One row of the covariance matrix at a time. Fix i. By linearity in the second slot,

    Cov(Xi​,Xˉ)=n1​j=1∑n​Cov(Xi​,Xj​)=n1​(Var(Xi​)+j=i∑​Cov(Xi​,Xj​))=n1​(σ2+0)=nσ2​,

    since the j=i terms vanish by pairwise uncorrelatedness. For the variance, use Var(Xˉ)=Cov(Xˉ,Xˉ) and linearity in the first slot:

    Var(Xˉ)=n1​i=1∑n​Cov(Xi​,Xˉ)=n1​⋅n⋅nσ2​=nσ2​.

    (Equivalently, the corollary on the variance of a linear combination with all ai​=n1​ and no cross terms gives n⋅n21​σ2.) ■

    (c) Residual against mean. By bilinearity and (b),

    Cov(Xi​−Xˉ,Xˉ)=Cov(Xi​,Xˉ)−Cov(Xˉ,Xˉ)=nσ2​−nσ2​=0.

    For the variance, apply the variance-of-a-sum theorem to Xi​+(−1)Xˉ:

    Var(Xi​−Xˉ)=Var(Xi​)+Var(Xˉ)−2Cov(Xi​,Xˉ)=σ2+nσ2​−n2σ2​=σ2(1−n1​)=n(n−1)σ2​.

    Each residual is a little less variable than the observations themselves, because Xˉ has already absorbed a n1​ share of Xi​. Summing the n residual variances gives (n−1)σ2, which is exactly why a sample variance divides the sum of squared residuals by n−1 rather than n.

  3. 3.Computation

    Let X and Y be independent with Var(X)=1 and Var(Y)=4, and put U=X+Y and V=X−Y.

    1. (a)Compute Cov(U,V), Var(U) and Var(V), and hence ρ(U,V).
    2. (b)Now let Var(X)=a and Var(Y)=b, both strictly positive, with X and Y still independent. Show that ρ(U,V)=a+ba−b​. Explain why this can never equal ±1 — both directly from the formula and from the equality case of the correlation bound — and say exactly when it equals 0.
    3. (c)Return to a=1, b=4. Write down ρ(U,2−3V) and ρ(−U,−V), naming the result you use.

    Solution

    (a) Bilinearity, with the cross term killed by independence. Since X and Y are independent, Cov(X,Y)=0 by the theorem that independence implies zero covariance. Expanding,

    Cov(U,V)=Cov(X+Y,X−Y)=Var(X)−Var(Y)=1−4=−3,

    the two Cov(X,Y) terms cancelling by symmetry regardless. By the variance-of-a-sum theorem, Var(U)=1+4+0=5 and Var(V)=1+4−0=5. Therefore

    ρ(U,V)=5​5​−3​=−53​.

    (b) The general formula. The same computation gives Cov(U,V)=a−b and Var(U)=Var(V)=a+b, so ρ(U,V)=a+b​a+b​a−b​=a+ba−b​.

    Directly: since a,b>0 we have ∣a−b∣<a+b, so ∣ρ∣<1 strictly.

    From the equality case of the correlation bound: ∣ρ(U,V)∣=1 would force V=α+βU almost surely for constants α, β=0, i.e. (1−β)X=α+(1+β)Y almost surely. If β=1 this makes X an affine function of Y; but X is independent of Y, hence independent of every function of Y, hence independent of itself, and a variable independent of itself satisfies P(X≤t)=P(X≤t)2 for every t and so is constant — contradicting a>0. If β=1 the relation reads 2Y=−α, so Y is constant, contradicting b>0. Either way an exact linear relation between U and V is impossible, which is what the formula was saying.

    ρ(U,V)=0 exactly when a=b: the sum and difference of two independent variables are uncorrelated precisely when the variances match.

    (c) Correlation is unit-free. By the proposition that ρ(aX+b,cY+d)=sign(ac)ρ(X,Y): for ρ(U,2−3V) the scale factors are 1 and −3, so the sign flips and ρ(U,2−3V)=+53​. For ρ(−U,−V) the factors are −1 and −1, whose product is positive, so ρ(−U,−V)=−53​, unchanged.

  4. 4.Computation

    Let X be uniform on the four values {−2,−1,1,2} and let Y=∣X∣.

    1. (a)Compute E[X], E[Y], E[XY] and hence Cov(X,Y).
    2. (b)Show that X and Y are not independent by exhibiting one pair of events for which the product rule fails.
    3. (c)Compute Var(X+Y) in two ways: from the variance-of-a-sum identity, and directly from the pmf of X+Y. State the hypothesis that licenses dropping the cross term, and say whether it is independence.
    4. (d)Compute E[X2Y] and E[X2]E[Y]. Are they equal? Explain what the comparison shows about which factorisation rules are available for an uncorrelated pair.

    Solution

    (a) Odd symmetry kills the cross moment. The distribution of X is symmetric about 0, so E[X]=41​(−2−1+1+2)=0. Next Y=∣X∣ takes the value 2 with probability 21​ and 1 with probability 21​, so E[Y]=23​. The product XY=X∣X∣ takes the values −4,−1,1,4 with probability 41​ each, so E[XY]=0. By the computational formula,

    Cov(X,Y)=E[XY]−E[X]E[Y]=0−0⋅23​=0.

    X and Y are uncorrelated.

    (b) One failing pair of events suffices. Take {X=1} and {Y=2}. They cannot both happen, since X=1 forces Y=1, so P(X=1,Y=2)=0. But P(X=1)P(Y=2)=41​⋅21​=81​=0. The product rule fails, so X and Y are not independent. (Indeed Y is a function of X: they are as dependent as possible, and still uncorrelated.)

    (c) Two routes to Var(X+Y). Var(X)=E[X2]−0=41​(4+1+1+4)=25​. E[Y2]=21​(4)+21​(1)=25​, so Var(Y)=25​−49​=41​. By the variance-of-a-sum theorem,

    Var(X+Y)=25​+41​+2⋅0=411​.

    Directly: X+Y=X+∣X∣ equals 0 when X=−2 or X=−1, equals 2 when X=1, and equals 4 when X=2. So X+Y is 0 with probability 21​, 2 with probability 41​, 4 with probability 41​. Then E[X+Y]=21​+1=23​ and E[(X+Y)2]=41​⋅4+41​⋅16=5, so Var(X+Y)=5−49​=411​. ✓

    The hypothesis used to drop the cross term is only Cov(X,Y)=0 — uncorrelatedness. It is not independence, and (b) shows independence is false here; the identity did not need it.

    (d) Where uncorrelatedness stops. X2Y=∣X∣2∣X∣=∣X∣3 takes the values 8,1,1,8 with probability 41​ each, so E[X2Y]=418​=29​. On the other hand E[X2]E[Y]=25​⋅23​=415​. They are not equal.

    Uncorrelated means exactly one factorisation, E[XY]=E[X]E[Y]. Independence would give E[g(X)h(Y)]=E[g(X)]E[h(Y)] for every pair of functions, and here g(x)=x2, h(y)=y already breaks it. So for an uncorrelated pair you may add variances, but you may not factorise expectations of products of arbitrary functions — that requires genuine independence.

  5. 5.Computation

    Let (X,Y) have joint density f(x,y)=8xy on the triangle 0<x<y<1, and 0 elsewhere.

    1. (a)Find the marginal density fY​ and the conditional density fX∣Y​(x∣y), checking that the latter integrates to 1. Compute E[X∣Y=y].
    2. (b)Write down the random variable E[X∣Y]. Compute the number E[X∣Y=21​] and the number Var(E[X∣Y]), and explain why the expression Var(E[X∣Y=21​]) is not a meaningful thing to ask for.
    3. (c)Compute E[XY∣Y] and E[X2∣Y], each as an explicit function of Y, naming the property that lets Y pass through the conditional expectation.
    4. (d)Find fY∣X​(y∣x) and E[Y∣X=x] in closed form, and check that E[Y∣X=x]>x for every x∈(0,1).

    Solution

    (a) Slice, then normalise. For 0<y<1 the marginal is

    fY​(y)=∫0y​8xydx=8y⋅2y2​=4y3,

    which integrates to 1 over (0,1) as it must. The conditional density is the joint divided by the marginal:

    fX∣Y​(x∣y)=4y38xy​=y22x​,0<x<y,

    and ∫0y​y22x​dx=y2y2​=1. ✓ Its mean is

    E[X∣Y=y]=∫0y​x⋅y22x​dx=y22​⋅3y3​=32y​.

    Given Y=y, the variable X has a density increasing linearly across (0,y), so its mean sits two-thirds of the way along — a sensible answer.

    (b) Substitute the random variable for the value. The function g(y)=32y​ evaluated at Y gives the random variable E[X∣Y]=32​Y. The number E[X∣Y=21​]=g(21​)=31​.

    For the variance of E[X∣Y] we need the moments of Y: E[Y]=∫01​4y4dy=54​ and E[Y2]=∫01​4y5dy=64​=32​, so Var(Y)=32​−2516​=7550−48​=752​. Hence

    Var(E[X∣Y])=Var(32​Y)=94​⋅752​=6758​.

    E[X∣Y=21​] is the single number 31​: the mean of X in the sub-population where Y=21​. A number has no distribution, so asking for its variance is a type error (or, if one insists, trivially 0). Only the random variable E[X∣Y], which varies with Y, has a variance worth computing — and it is 6758​, not 0.

    (c) Taking out what is known. Conditional on Y, the factor Y is a constant, so by the take-out-what-is-known property E[XY∣Y]=YE[X∣Y]=32​Y2. For the second moment, compute in the conditional world:

    E[X2∣Y=y]=∫0y​x2⋅y22x​dx=y22​⋅4y4​=2y2​,soE[X2∣Y]=2Y2​.

    (d) Condition the other way. The marginal of X is, for 0<x<1,

    fX​(x)=∫x1​8xydy=4x(1−x2),

    and ∫01​(4x−4x3)dx=2−1=1. ✓ Then

    fY∣X​(y∣x)=4x(1−x2)8xy​=1−x22y​,x<y<1,

    and

    E[Y∣X=x]=∫x1​1−x22y2​dy=1−x22​⋅31−x3​=3(1+x)2(1+x+x2)​,

    using 1−x3=(1−x)(1+x+x2) and 1−x2=(1−x)(1+x). Sanity checks: as x→1 the value tends to 3⋅22⋅3​=1, and at x=0 it is 32​, the mean of the density 2y on (0,1).

    For the inequality, E[Y∣X=x]>x is equivalent to 2(1+x+x2)>3x(1+x), i.e. 2−x−x2>0, i.e. (2+x)(1−x)>0, which holds throughout (0,1). This had to be true: given X=x, the variable Y lives on (x,1), so its conditional mean exceeds x.

  6. 6.Computation

    Use the tower property in every part. State clearly what you condition on, and write out the random variable E[⋅∣⋅] before you average it.

    1. (a)A coin's bias P is equally likely to be 41​, 21​ or 43​. Given P=p, the coin is tossed four times independently and X is the number of heads. Find E[X∣P], E[X] and P(X=4). Explain why P(X=4) is not (E[P])4.
    2. (b)The number N of customers entering a shop in an hour is Poisson with mean 6. Each customer, independently of N and of the other customers, buys 0, 1 or 2 items with probabilities 21​, 31​, 61​. Find the expected number of items sold in the hour, naming the theorem you use and checking its hypotheses.
    3. (c)A fair coin is tossed repeatedly. Let T be the number of tosses up to and including the first time two consecutive heads appear. By conditioning on the first toss — and, when it is a head, on the second toss as well — set up an equation for m=E[T] and solve it. You may take E[T]<∞ as given.

    Solution

    (a) Condition on the bias. Given P=p the count X is binomial with n=4 and success probability p, so E[X∣P=p]=4p; substituting the random variable, E[X∣P]=4P. By the tower property,

    E[X]=E[E[X∣P]]=4E[P]=4⋅31​(41​+21​+43​)=4⋅31​⋅23​=2.

    For the probability, write it as the expectation of an indicator and condition: P(X=4)=E[P(X=4∣P)], and P(X=4∣P=p)=p4. So

    P(X=4)=E[P4]=31​(2561​+25616​+25681​)=31​⋅25698​=76898​=38449​.

    By contrast (E[P])4=(21​)4=161​=38424​, about half as large. The tower property averages the conditional probabilities p4; it does not let you average p first and then raise to the fourth power, because p↦p4 is not linear. (It is convex, so the true answer is the larger one — that is Jensen's inequality.)

    (b) Wald's identity. Let Xi​ be the number of items bought by the i-th customer and SN​=X1​+⋯+XN​. The Xi​ are i.i.d. with finite mean

    μ=0⋅21​+1⋅31​+2⋅61​=31​+31​=32​,

    N is non-negative integer valued with finite mean 6, and N is independent of the sequence (Xi​). Those are exactly the hypotheses of Wald's identity. Conditioning on N: on {N=n} the sum has n terms whose distribution is unaffected by the conditioning, so E[SN​∣N=n]=nμ and E[SN​∣N]=32​N. Then

    E[SN​]=E[32​N]=32​⋅6=4 items.

    (c) First-step analysis. Condition on the first toss, and if it is a head, on the second. Three cases cover everything:

    First toss tails (probability 21​): one toss has been spent and nothing has been achieved. The tosses that follow are a fresh independent sequence, so the remaining wait has the same distribution as T: E[T∣T]=1+m.

    First toss heads, second tails (probability 41​): two tosses spent, and again the process restarts from scratch: E[T∣HT]=2+m.

    First two tosses heads (probability 41​): finished, T=2.

    By the tower property (the law of total expectation over these three events),

    m=21​(1+m)+41​(2+m)+41​⋅2=21​+2m​+21​+4m​+21​=23​+43m​.

    Hence 4m​=23​ and m=E[T]=6. The finiteness of E[T] is what permits subtracting 43m​ from both sides. Sanity check: a single head takes 2 tosses on average, and a run of two must take longer; 6 is plausible.

  7. 7.Critique

    A course has two sections. A randomly chosen student is in section A with probability 53​ and in section B with probability 52​. Let Y be the student's section and X their exam score. Within section A the scores have mean 70 and standard deviation 10; within section B they have mean 80 and standard deviation 10. A student writes:

    Step 1. The mean score is E[X]=270+80​=75.

    Step 2. By the law of total variance, Var(X)=E[Var(X∣Y)]=2100+100​=100, since each section has variance 100.

    Step 3. The other term, Var(E[X∣Y]), is zero: E[X∣Y=A]=70 is a constant, and a constant has no variance. So the standard deviation of a random student's score is 10.

    1. (a)Identify every error. For each, say which step it is in, which rule is being misapplied, and whether it happens to change the number in this particular instance.
    2. (b)Compute E[X] and Var(X) correctly, and state the fraction of Var(X) that is explained by section membership.
    3. (c)Suppose section B's standard deviation is changed from 10 to 20, everything else unchanged. Recompute Var(X) and say which of the two components moved.

    Solution

    (a) Three errors, one per step.

    Step 1 averages without weights. The tower property says E[X]=∑y​E[X∣Y=y]P(Y=y): the group means are weighted by group size. A plain average is right only when the groups are equally likely, and here they are not. This changes the number: 53​⋅70+52​⋅80=42+32=74, not 75.

    Step 2 drops a term and again forgets the weights. The law of total variance has two terms, E[Var(X∣Y)]+Var(E[X∣Y]); writing only the first is not the law. Also, the within term is itself a weighted average, 53​⋅100+52​⋅100. Because the two conditional variances happen to be equal, the missing weights do not change the number here (100 either way) — but the method is wrong and would fail the moment the sections had different spreads, as (c) shows.

    Step 3 is a type error. E[X∣Y=A]=70 is indeed a number, but Var(E[X∣Y]) is the variance of the random variable E[X∣Y], which equals 70 on {Y=A} and 80 on {Y=B} — it takes two values and is not constant. Confusing the number E[X∣Y=y] with the random variable E[X∣Y] is precisely what makes the between-group term disappear. This changes the number.

    (b) The correct computation. E[X]=74 from above.

    Between term: E[X∣Y] takes 70 with probability 53​ and 80 with probability 52​, with mean 74, so

    Var(E[X∣Y])=53​(70−74)2+52​(80−74)2=53​⋅16+52​⋅36=548​+572​=24.

    (For a two-point variable this is p(1−p)d2=53​⋅52​⋅102=24, a useful check.)

    Within term: E[Var(X∣Y)]=53​⋅100+52​⋅100=100.

    By the law of total variance, Var(X)=100+24=124, so the standard deviation is 124​=231​, a little over 11 rather than 10. The fraction explained by section is the between share, 12424​=316​.

    (c) Only the within term moves. The conditional means are untouched, so the between term is still 24. The within term becomes 53​⋅100+52​⋅400=60+160=220 — and now the unweighted average 2100+400​=250 would be wrong, which is the error Step 2 was lucky to hide. Hence Var(X)=220+24=244.

  8. 8.Computation

    Two random-mixture variances, each to be split into its within and between parts.

    1. (a)A coin's bias P is equally likely to be 41​, 21​ or 43​; given P=p, the coin is tossed four times and X is the number of heads. Compute Var(X) by the law of total variance, giving the within and between components separately. Compare with the variance of the number of heads in four tosses of a fair coin, and explain in one sentence where the difference comes from.
    2. (b)Customers arrive at a shop as N∼Poisson(6); each buys 0, 1 or 2 items with probabilities 21​, 31​, 61​, independently of N and of each other. Let SN​ be the total number of items sold. Compute Var(SN​) from the random-sum formula, identifying the two components. Then show that for a Poisson N with mean λ and any item distribution, Var(SN​)=λE[X12​].
    3. (c)Check your answer to (a) independently by computing E[X2] with the tower property.

    Solution

    (a) Within plus between. Given P, the count is binomial, so E[X∣P]=4P and Var(X∣P)=4P(1−P). The moments of P: E[P]=31​(41​+21​+43​)=21​ and E[P2]=31​(161​+164​+169​)=4814​=247​, so Var(P)=247​−41​=241​.

    Within: E[Var(X∣P)]=E[4P−4P2]=4(21​−247​)=4⋅245​=65​.

    Between: Var(E[X∣P])=Var(4P)=16⋅241​=32​.

    By the law of total variance, Var(X)=65​+32​=65+4​=23​.

    A fair coin tossed four times has variance 4⋅21​⋅21​=1. The mixture is more variable by 21​: not knowing the bias adds a between-group term of 32​ that a fixed coin does not have (it also trims the within term slightly, from 1 to 65​, because p(1−p) is largest at p=21​, but the between term dominates).

    (b) Variance of a random sum. With Xi​ the items bought by customer i: μ=E[X1​]=31​+62​=32​, E[X12​]=31​+64​=1, so σ2=1−94​=95​. For a Poisson, E[N]=Var(N)=6. By the corollary on the variance of a random sum,

    Var(SN​)=E[N]σ2+Var(N)μ2=6⋅95​+6⋅94​=930​+924​=6.

    The first term, 310​, is the within part (uncertainty about how much each customer buys); the second, 38​, is the between part (uncertainty about how many customers there are).

    In general, when N is Poisson with mean λ the two coefficients coincide, E[N]=Var(N)=λ, so

    Var(SN​)=λσ2+λμ2=λ(σ2+μ2)=λE[X12​],

    by the computational formula for the variance. Here λE[X12​]=6⋅1=6. ✓

    (c) Direct check via E[X2]. In the conditional world, E[X2∣P]=Var(X∣P)+(E[X∣P])2=4P(1−P)+16P2=4P+12P2. By the tower property,

    E[X2]=4E[P]+12E[P2]=4⋅21​+12⋅247​=2+27​=211​.

    Since E[X]=4E[P]=2, Var(X)=211​−4=23​, agreeing with (a). ✓

  9. 9.Computation

    Y is equally likely to be 0, 1 or 2. Given Y=0, X=0. Given Y=1, X is equally likely to be 1 or 3. Given Y=2, X is equally likely to be 0 or 2.

    1. (a)Write down the random variable m(Y)=E[X∣Y] and compute its mean squared error E[(X−m(Y))2] as a predictor of X.
    2. (b)Find the best linear predictor a∗+b∗Y of X from Y, and compute its mean squared error in two ways: from the formula Var(X)(1−ρ2), and from the decomposition E[(X−a−bY)2]=E[(X−m(Y))2]+E[(m(Y)−a−bY)2].
    3. (c)Find the best constant predictor and its mean squared error, and rank the three predictors.
    4. (d)Compare ρ2 with Var(m(Y))/Var(X). Say what each fraction measures and why they differ here.

    Solution

    (a) The conditional mean and its error. The group means are m(0)=0, m(1)=21+3​=2, m(2)=20+2​=1. So m(Y) takes the values 0, 2, 1 with probability 31​ each — note it is not monotone in Y.

    By the theorem that conditional expectation minimises mean squared error, its error is E[Var(X∣Y)]. The conditional variances are Var(X∣Y=0)=0, and for the two-point groups {1,3} and {0,2}, each symmetric about its mean at distance 1, Var(X∣Y=1)=Var(X∣Y=2)=1. Hence

    E[(X−m(Y))2]=31​(0+1+1)=32​.

    (b) The best line. First the moments. E[Y]=1 and Var(Y)=31​(1+0+1)=32​. By the tower property E[X]=E[m(Y)]=31​(0+2+1)=1 and, taking out what is known, E[XY]=E[Ym(Y)]=31​(0⋅0+1⋅2+2⋅1)=34​, so Cov(X,Y)=34​−1=31​. For Var(X), E[X2∣Y] takes the values 0, 21+9​=5, 20+4​=2, so E[X2]=31​(0+5+2)=37​ and Var(X)=37​−1=34​.

    By the proposition on the best linear predictor,

    b∗=Var(Y)Cov(X,Y)​=2/31/3​=21​,a∗=E[X]−b∗E[Y]=1−21​=21​,

    so the best line is 21​+21​Y, predicting 21​, 1, 23​ at Y=0,1,2.

    Via the formula: ρ2=Var(X)Var(Y)Cov(X,Y)2​=(4/3)(2/3)1/9​=8/91/9​=81​, so the error is Var(X)(1−ρ2)=34​⋅87​=67​.

    Via the decomposition: the gaps between the line and m(Y) at Y=0,1,2 are 21​−0, 1−2, 23​−1, with squares 41​, 1, 41​ and mean 31​⋅23​=21​. Adding the irreducible error from (a), 32​+21​=67​. ✓ (The cross term vanishes because X−m(Y) is uncorrelated with every function of Y, which is what makes the decomposition Pythagorean.)

    (c) The best constant. By the corollary on the best constant predictor, the minimiser is c=E[X]=1 with error Var(X)=34​. Ranking the errors: conditional mean 32​ < best line 67​ < best constant 34​. Each enlargement of the class of allowed predictors can only help, and here each one does.

    (d) Two different fractions of variance explained. ρ2=81​ is the fraction of Var(X) removed by the best linear predictor: indeed 4/34/3−7/6​=4/31/6​=81​.

    Var(m(Y))=E[m(Y)2]−1=31​(0+4+1)−1=32​, so Var(X)Var(m(Y))​=4/32/3​=21​. By the law of total variance this is the between share — the fraction of Var(X) removed by the best predictor of any form, since the remaining 32​ is exactly the within term.

    They differ because m(Y) is not a linear function of Y: it goes 0,2,1, and a straight line can only capture the tilt of that pattern, not its bend. The gap 21​−81​=83​ of the variance is the price of insisting on a line. Had m been linear in Y, the two fractions would coincide.

  10. 10.Sketch

    Let X take the value 1 with probability 43​ and the value 4 with probability 41​, and let φ(x)=1/x on (0,∞).

    1. (a)Compute E[X], φ(E[X]) and E[φ(X)], and state which inequality the comparison illustrates, verifying its hypothesis on φ.
    2. (b)Sketch y=1/x for 21​≤x≤5. Mark the two points of the graph above x=1 and x=4 and draw the chord joining them. Mark the point of the chord above x=E[X] and the point of the curve above x=E[X], label both with their exact heights, and explain why the chord's height there is exactly E[φ(X)] and not merely some average. Then draw the supporting line to the curve at μ=E[X], label its slope, and mark where it crosses the vertical lines x=1 and x=4.
    3. (c)From the picture: which two marked points would have to coincide for equality in Jensen's inequality, and what does that say about X? Then, without a sketch, redo (a) for φ(x)=x​ and say which feature of the picture reverses.

    Solution

    (a) The numbers. E[X]=43​⋅1+41​⋅4=43​+1=47​, so φ(E[X])=74​. And E[φ(X)]=E[1/X]=43​⋅1+41​⋅41​=43​+161​=1613​.

    Since 1613​=11291​ and 74​=11264​, we have E[φ(X)]>φ(E[X]), with gap 11227​. This is Jensen's inequality for a convex φ: on (0,∞), φ′′(x)=2/x3>0, so 1/x is strictly convex there, and X takes values in (0,∞) with probability one.

    (b) The drawing, feature by feature. The curve y=1/x is decreasing and bends upward (convex) through (21​,2), (1,1), (2,21​), (4,41​), (5,51​).

    The chord. It joins (1,1) to (4,41​); its slope is 31/4−1​=−41​ and its equation is y=1−41​(x−1)=45−x​. Because φ is convex, the chord lies above the curve on (1,4) — draw it so.

    The two marked points above x=47​. On the chord, y=45−7/4​=1613​; on the curve, y=74​. Label them (47​,1613​) and (47​,74​); the vertical gap between them is E[φ(X)]−φ(E[X])=11227​.

    Why the chord point is E[φ(X)]. The point 43​(1,1)+41​(4,41​) is a weighted average of the two endpoints of the chord, with the weights of the distribution, so it lies on the chord. Its x-coordinate is 43​⋅1+41​⋅4=E[X] and its y-coordinate is 43​φ(1)+41​φ(4)=E[φ(X)]. So the chord point above E[X] is not a generic average — it is the exact point (E[X],E[φ(X)]), sitting one quarter of the way from (1,1) to (4,41​). The curve point below it is (E[X],φ(E[X])). Jensen's inequality is the statement that the first lies above the second.

    The supporting line at μ=47​. Since φ is differentiable the supporting line is the tangent, with slope φ′(μ)=−1/μ2=−4916​:

    y=74​−4916​(x−47​)=78​−4916​x.

    It touches the curve at (47​,74​) and lies below the curve everywhere else. At x=1 its height is 78​−4916​=4940​<1, and at x=4 it is 78​−4964​=−498​<41​; mark both crossings. (It meets the x-axis at x=27​.) A check that reproduces the proof of Jensen: the expected height of the tangent at X is 43​⋅4940​+41​⋅(−498​)=4930−2​=74​=φ(μ), because a line through (μ,φ(μ)) has expectation φ(μ) when E[X−μ]=0. Since φ(X) lies above the tangent at both mass points, E[φ(X)]≥φ(μ) — the picture is the proof.

    (c) Equality, and the concave case. Equality in Jensen would mean the chord point (E[X],E[φ(X)]) coincides with the curve point (E[X],φ(E[X])). For a strictly convex curve the chord lies strictly above the graph between its endpoints, so the two points can only coincide if the chord has no interior — its endpoints are the same point — i.e. the two mass points of X are equal and X is constant almost surely. That is the equality clause of Jensen's inequality for strictly convex φ.

    For φ(x)=x​: φ′′(x)=−41​x−3/2<0, so φ is strictly concave and the inequality reverses. Numerically E[X​]=43​⋅1+41​⋅2=45​, while E[X]​=7/4​=27​​; since (45​)2=1625​<1628​=47​, we have E[X​]<E[X]​. ✓ The feature that reverses is the position of the chord: for a concave curve the chord lies below the graph, so the point (E[X],E[φ(X)]) now sits under the curve point rather than over it, and the supporting line sits above the curve.

  11. 11.Proof

    Let X have finite variance, let Y be any random variable, and write m(Y)=E[X∣Y]. Let h be any function with E[h(Y)2]<∞. Quote the tower property and the properties of conditional expectation by name wherever you use them. (You may take for granted that every expectation written below is finite; that follows from the Cauchy–Schwarz inequality.)

    1. (a)Prove that E[(X−m(Y))h(Y)]=0. Deduce that Cov(X,h(Y))=Cov(m(Y),h(Y)).
    2. (b)Deduce that the best linear predictor of X from Y is the same as the best linear predictor of m(Y) from Y, and that, when Var(X) and Var(Y) are positive, ρ(X,Y)2≤Var(m(Y))/Var(X).
    3. (c)Prove that Var(X)=Var(X−m(Y))+Var(m(Y)), and hence that Var(m(Y))≤Var(X) with equality if and only if X=m(Y) almost surely. Explain how this identity is the law of total variance.

    Solution

    (a) The prediction error is orthogonal to every function of Y. By the tower property,

    E[(X−m(Y))h(Y)]=E[E[(X−m(Y))h(Y)​Y]].

    Inside, h(Y) is a function of Y, so by the property taking out what is known it passes through the conditional expectation:

    E[(X−m(Y))h(Y)∣Y]=h(Y)E[X−m(Y)∣Y]=h(Y)(E[X∣Y]−m(Y))=h(Y)⋅0=0,

    where the middle step uses linearity of conditional expectation and, once more, taking out what is known applied to m(Y), itself a function of Y. The outer expectation of the zero random variable is 0. ■

    For the covariance, bilinearity gives Cov(X,h(Y))−Cov(m(Y),h(Y))=Cov(X−m(Y),h(Y)), and by the computational formula

    Cov(X−m(Y),h(Y))=E[(X−m(Y))h(Y)]−E[X−m(Y)]E[h(Y)]=0−0⋅E[h(Y)]=0,

    since the first term vanishes by what was just proved and E[X−m(Y)]=E[X]−E[m(Y)]=0 by the tower property. Hence Cov(X,h(Y))=Cov(m(Y),h(Y)). ■

    (b) Regression only sees the conditional mean. By the proposition on the best linear predictor, the line predicting X from Y has slope b∗=Cov(X,Y)/Var(Y) and intercept a∗=E[X]−b∗E[Y]. Take h(y)=y in (a): Cov(X,Y)=Cov(m(Y),Y), so the slope is the same for m(Y); and E[X]=E[m(Y)] by the tower property, so the intercept is the same too. The two best lines coincide. ■

    For the bound, ρ(X,Y)2=Var(X)Var(Y)Cov(X,Y)2​=Var(X)Var(Y)Cov(m(Y),Y)2​. If Var(m(Y))=0 then m(Y) is almost surely constant, its covariance with Y is 0, and the inequality reads 0≤0. Otherwise the correlation bound (Cauchy–Schwarz applied to the centred pair m(Y)−E[m(Y)] and Y−E[Y]) gives Cov(m(Y),Y)2≤Var(m(Y))Var(Y), and dividing,

    ρ(X,Y)2≤Var(X)Var(Y)Var(m(Y))Var(Y)​=Var(X)Var(m(Y))​.■

    The variance explained linearly can never exceed the variance explained by conditioning.

    (c) Pythagoras for variances. Write X=(X−m(Y))+m(Y). By the variance-of-a-sum theorem,

    Var(X)=Var(X−m(Y))+Var(m(Y))+2Cov(X−m(Y),m(Y)).

    Apply (a) with h=m (legitimate since E[m(Y)2]<∞): the covariance is E[(X−m(Y))m(Y)]−E[X−m(Y)]E[m(Y)]=0−0=0. The cross term vanishes and the identity follows. ■

    Since Var(X−m(Y))≥0, we get Var(m(Y))≤Var(X). Equality holds if and only if Var(X−m(Y))=0, i.e. X−m(Y) is almost surely equal to a constant; that constant is its mean, which is 0 by the tower property. So equality holds if and only if X=m(Y) almost surely — X is a function of Y, and conditioning on Y leaves nothing unexplained. ■

    As for the law of total variance: X−m(Y) has mean 0, so Var(X−m(Y))=E[(X−m(Y))2], and by the tower property this is E[E[(X−m(Y))2∣Y]]. The inner quantity is, by definition, Var(X∣Y) — the variance of X about its conditional mean, computed in the conditional world. So the identity reads Var(X)=E[Var(X∣Y)]+Var(E[X∣Y]), which is the law of total variance, with the within term revealed as the variance of the best predictor's error and the between term as the variance of the prediction itself.

  12. 12.Proof

    Quote Jensen's inequality, including its equality clause, wherever you use it, and verify the convexity or concavity of the function each time.

    1. (a)Let a1​,…,an​>0 and let w1​,…,wn​>0 with ∑i​wi​=1. Prove the weighted arithmetic–geometric mean inequality ∏i=1n​aiwi​​≤∑i=1n​wi​ai​, and show that equality holds if and only if all the ai​ are equal.
    2. (b)Let X≥0 and 0<r<s with E[Xs]<∞. Prove Lyapunov's inequality (E[Xr])1/r≤(E[Xs])1/s. (Apply Jensen to U=Xr and φ(u)=us/r; explain why E[U] is finite.)
    3. (c)Specialise (b) to r=1, s=2, and show the resulting inequality is also the Cauchy–Schwarz inequality for a suitable pair of variables. Then, for X equal to 1 with probability 43​ and to 4 with probability 41​, compute (E[X​])2 and E[X] and check that they are ordered as (b) with r=21​, s=1 predicts.

    Solution

    (a) AM–GM is Jensen for the logarithm. Let X be the random variable taking the value ai​ with probability wi​ (if some values coincide, their probabilities add). Then X>0 with probability one, E[X]=∑i​wi​ai​, and by the law of the unconscious statistician E[logX]=∑i​wi​logai​=log∏i​aiwi​​.

    On (0,∞), φ(x)=logx has φ′′(x)=−1/x2<0, so it is strictly concave. Jensen's inequality for a concave function gives E[logX]≤logE[X], that is,

    logi∏​aiwi​​≤logi∑​wi​ai​.

    Since exp is increasing, ∏i​aiwi​​≤∑i​wi​ai​. ■

    By the equality clause for a strictly concave (equivalently, −log strictly convex) function, equality holds if and only if X is almost surely constant. Every wi​ is positive, so each ai​ is a value taken with positive probability, and "almost surely constant" means all ai​ equal that one constant. Conversely if all ai​=a both sides equal a. ■

    (b) Lyapunov's inequality. Put U=Xr≥0 and q=s/r>1, so that Uq=Xs and E[Uq]=E[Xs]<∞. First, E[U] is finite: for u≥0 we have u≤1+uq (if u≤1 then u≤1; if u>1 then u<uq because q>1), so by monotonicity of expectation E[U]≤1+E[Uq]<∞. Thus U has a finite mean in [0,∞), and E[φ(U)]=E[Uq] exists.

    The function φ(u)=uq on [0,∞) is convex: on (0,∞) its second derivative q(q−1)uq−2 is positive because q>1, and φ is continuous at 0, so the chord condition holds on the whole closed half-line. By Jensen's inequality,

    (E[U])q=φ(E[U])≤E[φ(U)]=E[Uq],i.e.(E[Xr])s/r≤E[Xs].

    Both sides are non-negative and t↦t1/s is increasing on [0,∞), so raising both sides to the power 1/s preserves the inequality:

    (E[Xr])1/r≤(E[Xs])1/s.■

    (As φ is strictly convex, equality holds if and only if U, hence X, is almost surely constant.)

    (c) The case r=1, s=2, and a numerical check. With r=1, s=2 the inequality reads E[X]≤(E[X2])1/2, i.e. (E[X])2≤E[X2] for X≥0 — the statement that a variance is non-negative. The Cauchy–Schwarz inequality for random variables, applied to the pair U=X and V=1, gives

    (E[X⋅1])2≤E[X2]E[12]=E[X2],

    the same inequality; and its equality clause — X proportional to the constant 1 almost surely — is the same as Jensen's: X almost surely constant.

    For the two-point variable, E[X​]=43​⋅1+41​⋅2=45​, so (E[X​])2=1625​, while E[X]=43​+1=47​=1628​. Lyapunov with r=21​, s=1 predicts (E[X1/2])2≤E[X], and indeed 1625​<1628​ — strictly, as it must be since X is not constant. ✓

← Back to the question sheet

CalcPath·Free university mathematics

SubjectsProblem setsProgressFeedbackAbout