1.3.8 · D4Probability & Statistics

Exercises — Expectation, variance, and standard deviation

1,632 words7 min readBack to topic

The three tools we lean on all page long:

Above: think of expectation as the point where the "mass" of probability balances (magenta pivot), and variance/standard deviation as how wide the mass is smeared (violet band). Keep this picture in mind for every problem.


Level 1 — Recognition

These test whether you can read a distribution and plug into the definition.

Problem 1.1

A coin is flipped once. Let if heads, if tails, with . Find .

Recall Solution 1.1

What we do: apply directly. Why: each value is weighted by how likely it is. Heads contributes , tails contributes nothing because its value is . Answer: .

Problem 1.2

A random variable takes values with probabilities . Find .

Recall Solution 1.2

Why the negative term: a negative value pulls the balance point left, exactly as a mass placed on the left of a seesaw does. Answer: .

Problem 1.3

State which is measured in the same units as the data: variance or standard deviation? Why?

Recall Solution 1.3

Standard deviation. Variance is an average of squared deviations, so it carries units of (e.g. ). Taking the square root, , returns to — the original scale, which is why it is more interpretable. This is exactly why feature scaling uses , not , in .


Level 2 — Application

Now compute variance and SD, and use the scaling/shift rules.

Problem 2.1

For the coin of Problem 1.1 (), find and .

Recall Solution 2.1

Step 1 — compute . Because , note , so . Step 2 — apply Form 2: . Step 3 — SD: . Why Form 2: computing then subtracting avoids re-summing term by term. Answer: , .

Problem 2.2

Let . A new variable is . Find and .

Recall Solution 2.2

Scaling rule: , so the shift does nothing to spread and multiplies variance by . Why vanishes: adding a constant slides the whole distribution sideways — the shape and width are untouched, so spread cannot change. Answer: , .

Problem 2.3

, so on . Find and .

Recall Solution 2.3

Mean by integral: Second moment: Variance: . Sanity check: general Uniform variance is . ✓ Answer: , .


Level 3 — Analysis

Combine variables and reason about which rule applies.

Problem 3.1

and are independent dice-like variables with and . Find and .

Recall Solution 3.1

Independence lets variances add: . SD: . Why not add SDs: . Variances add; SDs do not. Answer: , .

Problem 3.2

are not independent: , , . Find .

Recall Solution 3.2

Use the general formula (see covariance): Why the sum shrank: negative covariance means when is high, tends low — they partly cancel, so the combined spread is smaller than . Answer: .

Problem 3.3

A gradient estimate from one sample has variance . A mini-batch averages independent estimates: . Find and .

Recall Solution 3.3

Step 1 — pull out the with the scaling rule (, so ): Step 2 — independent terms, so variances add: . Step 3: , and . Insight: averaging independent estimates divides variance by (here ), so SD drops by . This is exactly why larger mini-batches give steadier updates in gradient descent variants. Answer: , .


Level 4 — Synthesis

Chain several tools inside one problem.

Problem 4.1

A feature has , . You standardise it: . Prove and .

Recall Solution 4.1

Write , i.e. with , . Mean (linearity): Variance (scaling, shift-invariant): the shift does nothing, and : Why this matters: standardisation always yields mean , SD , regardless of the original — the backbone of normalization. Plugging in the numbers () is not even needed; the result is universal. Answer: , .

Problem 4.2

Let be a fair die (, ). Define . Find , , and .

Recall Solution 4.2

Mean: . Variance: shift irrelevant, factor squares: . SD: . (Equivalently .) Answer: , , .


Level 5 — Mastery

Prove a general result and design with it.

Problem 5.1

Prove the computational identity from the definition , where . State each rule you use.

Recall Solution 5.1

Step 1 — expand the square (algebra): Step 2 — take expectation, use linearity () and that is a constant: Step 3 — substitute : Step 4 — rewrite : Why it's useful: you compute and once each and subtract — far less work than summing over every outcome.

Problem 5.2

A Bernoulli variable has with probability and with probability . Show and . Then find which maximises the variance.

Recall Solution 5.2

Mean: . Second moment: since (values are and ), . Variance: . Maximising: treat . Its vertex (a downward parabola) is at , giving . So variance is largest, , when the outcome is maximally uncertain (a fair coin), and it is at or (a certain outcome has no spread). Answer: , , maximised at with variance .


Recall One-line self-check before you leave

Expectation is linear (shifts move it) ::: Variance kills shifts and squares scales ::: Independent sum ::: variances add, then square-root for SD Correlated sum ::: add as well

Related depth: 1.3.09-Covariance-and-correlation, 1.3.12-Central-limit-theorem, 3.2.04-Bias-variance-tradeoff, and the Hinglish walkthrough 1.3.08 Expectation, variance, and standard deviation (Hinglish).