Probability · Solutions
Expectation, Covariance and Conditional Expectation
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 and the random variable 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.Computation
The pair has the joint pmf
- (a)Find the marginal pmf of , the marginal pmf of , and and .
- (b)Compute from the computational formula. Then confirm its sign by deciding which cells of the table contribute positively to and which negatively, and by adding up those weighted contributions.
- (c)Compute and without finding the distribution of either variable. Then find the pmf of directly from the table and verify your value of .
- (d)Without any further computation, write down , naming the property you use.
Solution
(a) Marginals by summing the table. Column sums give the pmf of : , , . Row sums give the pmf of : and . Hence
(b) Computational formula. Only cells with both coordinates nonzero contribute to : the cell gives and the cell gives , so . By the computational formula for the covariance,
For the sign check, the deviations are and . In the cells , and the two deviations have the same sign, so those cells push the covariance up; in and they have opposite signs and push it down; the cell has probability zero and contributes nothing. Weighting each product of deviations by its cell probability,
the same number from the definition. It is positive because the two heaviest cells, and together with , all sit in the agreeing quadrants.
(c) Variance of a sum, no hypotheses. , so . is Bernoulli with , so . By the theorem on the variance of a sum, which needs no independence,
Direct check: reading off each cell, it equals on [probability ], on and [probability ], and on and [probability ]. So , which agrees with , and , giving . ✓
(d) Bilinearity. By the theorem on bilinearity and symmetry of covariance, additive shifts are invisible and scale factors come out of each slot: .
- 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 , and the variance-of-a-sum theorem. Independence is never assumed unless stated.
- (a)Prove that . Deduce that if and have the same variance then and are uncorrelated, whether or not and are independent.
- (b)Let be pairwise uncorrelated, each with variance , and let . Prove that for every , and that .
- (c)Deduce that each residual is uncorrelated with , and compute .
Solution
(a) Expand by bilinearity. Linearity in the first slot, then in the second, gives
By symmetry , so the two middle terms cancel, and the outer terms are and because variance is a self-covariance. Hence .
If the right-hand side is , which is the definition of and being uncorrelated. Nothing in the argument mentioned itself — it cancelled — so the conclusion holds however strongly and are related. (Uncorrelated is not the same as independent: for , independent with equal variances, and are uncorrelated but and are typically dependent.)
(b) One row of the covariance matrix at a time. Fix . By linearity in the second slot,
since the terms vanish by pairwise uncorrelatedness. For the variance, use and linearity in the first slot:
(Equivalently, the corollary on the variance of a linear combination with all and no cross terms gives .)
(c) Residual against mean. By bilinearity and (b),
For the variance, apply the variance-of-a-sum theorem to :
Each residual is a little less variable than the observations themselves, because has already absorbed a share of . Summing the residual variances gives , which is exactly why a sample variance divides the sum of squared residuals by rather than .
- 3.Computation
Let and be independent with and , and put and .
- (a)Compute , and , and hence .
- (b)Now let and , both strictly positive, with and still independent. Show that . Explain why this can never equal — both directly from the formula and from the equality case of the correlation bound — and say exactly when it equals .
- (c)Return to , . Write down and , naming the result you use.
Solution
(a) Bilinearity, with the cross term killed by independence. Since and are independent, by the theorem that independence implies zero covariance. Expanding,
the two terms cancelling by symmetry regardless. By the variance-of-a-sum theorem, and . Therefore
(b) The general formula. The same computation gives and , so .
Directly: since we have , so strictly.
From the equality case of the correlation bound: would force almost surely for constants , , i.e. almost surely. If this makes an affine function of ; but is independent of , hence independent of every function of , hence independent of itself, and a variable independent of itself satisfies for every and so is constant — contradicting . If the relation reads , so is constant, contradicting . Either way an exact linear relation between and is impossible, which is what the formula was saying.
exactly when : the sum and difference of two independent variables are uncorrelated precisely when the variances match.
(c) Correlation is unit-free. By the proposition that : for the scale factors are and , so the sign flips and . For the factors are and , whose product is positive, so , unchanged.
- 4.Computation
Let be uniform on the four values and let .
- (a)Compute , , and hence .
- (b)Show that and are not independent by exhibiting one pair of events for which the product rule fails.
- (c)Compute in two ways: from the variance-of-a-sum identity, and directly from the pmf of . State the hypothesis that licenses dropping the cross term, and say whether it is independence.
- (d)Compute and . 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 is symmetric about , so . Next takes the value with probability and with probability , so . The product takes the values with probability each, so . By the computational formula,
and are uncorrelated.
(b) One failing pair of events suffices. Take and . They cannot both happen, since forces , so . But . The product rule fails, so and are not independent. (Indeed is a function of : they are as dependent as possible, and still uncorrelated.)
(c) Two routes to . . , so . By the variance-of-a-sum theorem,
Directly: equals when or , equals when , and equals when . So is with probability , with probability , with probability . Then and , so . ✓
The hypothesis used to drop the cross term is only — uncorrelatedness. It is not independence, and (b) shows independence is false here; the identity did not need it.
(d) Where uncorrelatedness stops. takes the values with probability each, so . On the other hand . They are not equal.
Uncorrelated means exactly one factorisation, . Independence would give for every pair of functions, and here , 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.Computation
Let have joint density on the triangle , and elsewhere.
- (a)Find the marginal density and the conditional density , checking that the latter integrates to . Compute .
- (b)Write down the random variable . Compute the number and the number , and explain why the expression is not a meaningful thing to ask for.
- (c)Compute and , each as an explicit function of , naming the property that lets pass through the conditional expectation.
- (d)Find and in closed form, and check that for every .
Solution
(a) Slice, then normalise. For the marginal is
which integrates to over as it must. The conditional density is the joint divided by the marginal:
and . ✓ Its mean is
Given , the variable has a density increasing linearly across , so its mean sits two-thirds of the way along — a sensible answer.
(b) Substitute the random variable for the value. The function evaluated at gives the random variable . The number .
For the variance of we need the moments of : and , so . Hence
is the single number : the mean of in the sub-population where . A number has no distribution, so asking for its variance is a type error (or, if one insists, trivially ). Only the random variable , which varies with , has a variance worth computing — and it is , not .
(c) Taking out what is known. Conditional on , the factor is a constant, so by the take-out-what-is-known property . For the second moment, compute in the conditional world:
(d) Condition the other way. The marginal of is, for ,
and . ✓ Then
and
using and . Sanity checks: as the value tends to , and at it is , the mean of the density on .
For the inequality, is equivalent to , i.e. , i.e. , which holds throughout . This had to be true: given , the variable lives on , so its conditional mean exceeds .
- 6.Computation
Use the tower property in every part. State clearly what you condition on, and write out the random variable before you average it.
- (a)A coin's bias is equally likely to be , or . Given , the coin is tossed four times independently and is the number of heads. Find , and . Explain why is not .
- (b)The number of customers entering a shop in an hour is Poisson with mean . Each customer, independently of and of the other customers, buys , or items with probabilities , , . Find the expected number of items sold in the hour, naming the theorem you use and checking its hypotheses.
- (c)A fair coin is tossed repeatedly. Let 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 and solve it. You may take as given.
Solution
(a) Condition on the bias. Given the count is binomial with and success probability , so ; substituting the random variable, . By the tower property,
For the probability, write it as the expectation of an indicator and condition: , and . So
By contrast , about half as large. The tower property averages the conditional probabilities ; it does not let you average first and then raise to the fourth power, because is not linear. (It is convex, so the true answer is the larger one — that is Jensen's inequality.)
(b) Wald's identity. Let be the number of items bought by the -th customer and . The are i.i.d. with finite mean
is non-negative integer valued with finite mean , and is independent of the sequence . Those are exactly the hypotheses of Wald's identity. Conditioning on : on the sum has terms whose distribution is unaffected by the conditioning, so and . Then
(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 ): 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 : .
First toss heads, second tails (probability ): two tosses spent, and again the process restarts from scratch: .
First two tosses heads (probability ): finished, .
By the tower property (the law of total expectation over these three events),
Hence and . The finiteness of is what permits subtracting from both sides. Sanity check: a single head takes tosses on average, and a run of two must take longer; is plausible.
- 7.Critique
A course has two sections. A randomly chosen student is in section with probability and in section with probability . Let be the student's section and their exam score. Within section the scores have mean and standard deviation ; within section they have mean and standard deviation . A student writes:
Step 1. The mean score is .
Step 2. By the law of total variance, , since each section has variance .
Step 3. The other term, , is zero: is a constant, and a constant has no variance. So the standard deviation of a random student's score is .
- (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.
- (b)Compute and correctly, and state the fraction of that is explained by section membership.
- (c)Suppose section 's standard deviation is changed from to , everything else unchanged. Recompute and say which of the two components moved.
Solution
(a) Three errors, one per step.
Step 1 averages without weights. The tower property says : 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: , not .
Step 2 drops a term and again forgets the weights. The law of total variance has two terms, ; writing only the first is not the law. Also, the within term is itself a weighted average, . Because the two conditional variances happen to be equal, the missing weights do not change the number here ( 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. is indeed a number, but is the variance of the random variable , which equals on and on — it takes two values and is not constant. Confusing the number with the random variable is precisely what makes the between-group term disappear. This changes the number.
(b) The correct computation. from above.
Between term: takes with probability and with probability , with mean , so
(For a two-point variable this is , a useful check.)
Within term: .
By the law of total variance, , so the standard deviation is , a little over rather than . The fraction explained by section is the between share, .
(c) Only the within term moves. The conditional means are untouched, so the between term is still . The within term becomes — and now the unweighted average would be wrong, which is the error Step 2 was lucky to hide. Hence .
- 8.Computation
Two random-mixture variances, each to be split into its within and between parts.
- (a)A coin's bias is equally likely to be , or ; given , the coin is tossed four times and is the number of heads. Compute 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.
- (b)Customers arrive at a shop as ; each buys , or items with probabilities , , , independently of and of each other. Let be the total number of items sold. Compute from the random-sum formula, identifying the two components. Then show that for a Poisson with mean and any item distribution, .
- (c)Check your answer to (a) independently by computing with the tower property.
Solution
(a) Within plus between. Given , the count is binomial, so and . The moments of : and , so .
Within:
Between:
By the law of total variance, .
A fair coin tossed four times has variance . The mixture is more variable by : not knowing the bias adds a between-group term of that a fixed coin does not have (it also trims the within term slightly, from to , because is largest at , but the between term dominates).
(b) Variance of a random sum. With the items bought by customer : , , so . For a Poisson, . By the corollary on the variance of a random sum,
The first term, , is the within part (uncertainty about how much each customer buys); the second, , is the between part (uncertainty about how many customers there are).
In general, when is Poisson with mean the two coefficients coincide, , so
by the computational formula for the variance. Here . ✓
(c) Direct check via . In the conditional world, . By the tower property,
Since , , agreeing with (a). ✓
- 9.Computation
is equally likely to be , or . Given , . Given , is equally likely to be or . Given , is equally likely to be or .
- (a)Write down the random variable and compute its mean squared error as a predictor of .
- (b)Find the best linear predictor of from , and compute its mean squared error in two ways: from the formula , and from the decomposition .
- (c)Find the best constant predictor and its mean squared error, and rank the three predictors.
- (d)Compare with . Say what each fraction measures and why they differ here.
Solution
(a) The conditional mean and its error. The group means are , , . So takes the values , , with probability each — note it is not monotone in .
By the theorem that conditional expectation minimises mean squared error, its error is . The conditional variances are , and for the two-point groups and , each symmetric about its mean at distance , . Hence
(b) The best line. First the moments. and . By the tower property and, taking out what is known, , so . For , takes the values , , , so and .
By the proposition on the best linear predictor,
so the best line is , predicting , , at .
Via the formula: , so the error is .
Via the decomposition: the gaps between the line and at are , , , with squares , , and mean . Adding the irreducible error from (a), . ✓ (The cross term vanishes because is uncorrelated with every function of , which is what makes the decomposition Pythagorean.)
(c) The best constant. By the corollary on the best constant predictor, the minimiser is with error . Ranking the errors: conditional mean best line best constant . Each enlargement of the class of allowed predictors can only help, and here each one does.
(d) Two different fractions of variance explained. is the fraction of removed by the best linear predictor: indeed .
, so . By the law of total variance this is the between share — the fraction of removed by the best predictor of any form, since the remaining is exactly the within term.
They differ because is not a linear function of : it goes , and a straight line can only capture the tilt of that pattern, not its bend. The gap of the variance is the price of insisting on a line. Had been linear in , the two fractions would coincide.
- 10.Sketch
Let take the value with probability and the value with probability , and let on .
- (a)Compute , and , and state which inequality the comparison illustrates, verifying its hypothesis on .
- (b)Sketch for . Mark the two points of the graph above and and draw the chord joining them. Mark the point of the chord above and the point of the curve above , label both with their exact heights, and explain why the chord's height there is exactly and not merely some average. Then draw the supporting line to the curve at , label its slope, and mark where it crosses the vertical lines and .
- (c)From the picture: which two marked points would have to coincide for equality in Jensen's inequality, and what does that say about ? Then, without a sketch, redo (a) for and say which feature of the picture reverses.
Solution
(a) The numbers. , so . And .
Since and , we have , with gap . This is Jensen's inequality for a convex : on , , so is strictly convex there, and takes values in with probability one.
(b) The drawing, feature by feature. The curve is decreasing and bends upward (convex) through , , , , .
The chord. It joins to ; its slope is and its equation is . Because is convex, the chord lies above the curve on — draw it so.
The two marked points above . On the chord, ; on the curve, . Label them and ; the vertical gap between them is .
Why the chord point is . The point is a weighted average of the two endpoints of the chord, with the weights of the distribution, so it lies on the chord. Its -coordinate is and its -coordinate is . So the chord point above is not a generic average — it is the exact point , sitting one quarter of the way from to . The curve point below it is . Jensen's inequality is the statement that the first lies above the second.
The supporting line at . Since is differentiable the supporting line is the tangent, with slope :
It touches the curve at and lies below the curve everywhere else. At its height is , and at it is ; mark both crossings. (It meets the -axis at .) A check that reproduces the proof of Jensen: the expected height of the tangent at is , because a line through has expectation when . Since lies above the tangent at both mass points, — the picture is the proof.
(c) Equality, and the concave case. Equality in Jensen would mean the chord point coincides with the curve point . 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 are equal and is constant almost surely. That is the equality clause of Jensen's inequality for strictly convex .
For : , so is strictly concave and the inequality reverses. Numerically , while ; since , we have . ✓ The feature that reverses is the position of the chord: for a concave curve the chord lies below the graph, so the point now sits under the curve point rather than over it, and the supporting line sits above the curve.
- 11.Proof
Let have finite variance, let be any random variable, and write . Let be any function with . 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.)
- (a)Prove that . Deduce that .
- (b)Deduce that the best linear predictor of from is the same as the best linear predictor of from , and that, when and are positive, .
- (c)Prove that , and hence that with equality if and only if almost surely. Explain how this identity is the law of total variance.
Solution
(a) The prediction error is orthogonal to every function of . By the tower property,
Inside, is a function of , so by the property taking out what is known it passes through the conditional expectation:
where the middle step uses linearity of conditional expectation and, once more, taking out what is known applied to , itself a function of . The outer expectation of the zero random variable is .
For the covariance, bilinearity gives , and by the computational formula
since the first term vanishes by what was just proved and by the tower property. Hence .
(b) Regression only sees the conditional mean. By the proposition on the best linear predictor, the line predicting from has slope and intercept . Take in (a): , so the slope is the same for ; and by the tower property, so the intercept is the same too. The two best lines coincide.
For the bound, . If then is almost surely constant, its covariance with is , and the inequality reads . Otherwise the correlation bound (Cauchy–Schwarz applied to the centred pair and ) gives , and dividing,
The variance explained linearly can never exceed the variance explained by conditioning.
(c) Pythagoras for variances. Write . By the variance-of-a-sum theorem,
Apply (a) with (legitimate since ): the covariance is . The cross term vanishes and the identity follows.
Since , we get . Equality holds if and only if , i.e. is almost surely equal to a constant; that constant is its mean, which is by the tower property. So equality holds if and only if almost surely — is a function of , and conditioning on leaves nothing unexplained.
As for the law of total variance: has mean , so , and by the tower property this is . The inner quantity is, by definition, — the variance of about its conditional mean, computed in the conditional world. So the identity reads , 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.Proof
Quote Jensen's inequality, including its equality clause, wherever you use it, and verify the convexity or concavity of the function each time.
- (a)Let and let with . Prove the weighted arithmetic–geometric mean inequality , and show that equality holds if and only if all the are equal.
- (b)Let and with . Prove Lyapunov's inequality . (Apply Jensen to and ; explain why is finite.)
- (c)Specialise (b) to , , and show the resulting inequality is also the Cauchy–Schwarz inequality for a suitable pair of variables. Then, for equal to with probability and to with probability , compute and and check that they are ordered as (b) with , predicts.
Solution
(a) AM–GM is Jensen for the logarithm. Let be the random variable taking the value with probability (if some values coincide, their probabilities add). Then with probability one, , and by the law of the unconscious statistician .
On , has , so it is strictly concave. Jensen's inequality for a concave function gives , that is,
Since is increasing, .
By the equality clause for a strictly concave (equivalently, strictly convex) function, equality holds if and only if is almost surely constant. Every is positive, so each is a value taken with positive probability, and "almost surely constant" means all equal that one constant. Conversely if all both sides equal .
(b) Lyapunov's inequality. Put and , so that and . First, is finite: for we have (if then ; if then because ), so by monotonicity of expectation . Thus has a finite mean in , and exists.
The function on is convex: on its second derivative is positive because , and is continuous at , so the chord condition holds on the whole closed half-line. By Jensen's inequality,
Both sides are non-negative and is increasing on , so raising both sides to the power preserves the inequality:
(As is strictly convex, equality holds if and only if , hence , is almost surely constant.)
(c) The case , , and a numerical check. With , the inequality reads , i.e. for — the statement that a variance is non-negative. The Cauchy–Schwarz inequality for random variables, applied to the pair and , gives
the same inequality; and its equality clause — proportional to the constant almost surely — is the same as Jensen's: almost surely constant.
For the two-point variable, , so , while . Lyapunov with , predicts , and indeed — strictly, as it must be since is not constant. ✓