Expectation, Variance and Their Algebra
Statement
For random variables X, Y on a common probability space and constants a, b ∈ ℝ, expectation is linear, E[aX + bY] = aE[X] + bE[Y], the variance obeys Var(X) = E[X²] − (E[X])², and under an affine map the moments scale as E[aX + b] = aE[X] + b and Var(aX + b) = a²Var(X) — each following directly from the definition of expectation as a probability-weighted sum or integral.
Why it matters
These four identities are the entire arithmetic of first and second moments. Linearity holds without any independence assumption, which is why it is the single most-used tool in probability: it lets us decompose the mean of a complicated sum (a total across many trials, a sample mean, a sum of indicators) into a sum of simple pieces even when those pieces are strongly dependent.
The computational form Var(X) = E[X²] − (E[X])² converts a definition that requires knowing the mean first into a single pass over the second moment, and the affine scaling rules tell us exactly how the mean and spread respond to a change of units or origin — the foundation of standardisation, the z-score, and error propagation.
Assumptions
Derivation
Result
Reading. The mean of a linear combination is the same linear combination of the means, always — dependence is irrelevant. The variance is the second moment minus the square of the first. Adding a constant slides the whole distribution and leaves the spread untouched; multiplying by a stretches deviations by |a|, so variance (a squared quantity) scales by a².
Units check. If X carries units [u], then E[X] is in [u], E[X²] and (E[X])² are both in [u²], so Var(X) is in [u²] and the standard deviation σ = √Var returns to [u]. In Var(aX+b)=a²Var(X) the constant a carries [u′/u] and b carries [u′], matching both sides at [u′²].
Limiting cases
- Degenerate variable (X = c almost surely): E[X²] = c² = (E[X])², so Var(X) = 0 — no spread, as expected.
- Pure shift (a = 1): Var(X + b) = Var(X) — translating data never changes its spread.
- Sign flip (a = −1, b = 0): Var(−X) = Var(X) and E[−X] = −E[X].
- Standardisation (a = 1/σ, b = −μ/σ): Z = (X−μ)/σ has E[Z]=0, Var(Z)=1.
- Independent sum: linearity gives the mean freely; the variance of a sum needs Var(X+Y)=Var(X)+Var(Y)+2Cov(X,Y), reducing to the sum only when Cov = 0.
Breaks when
- Heavy tails with no finite mean. For a Cauchy variable the integral ∫ x f(x) dx diverges, so E[X] does not exist; "linearity of expectation" is a statement about a quantity that isn't there, and sample means wander forever instead of converging.
- Finite mean but infinite second moment. A Pareto with tail index 1 < α ≤ 2 has a well-defined E[X] but E[X²] = ∞, so Var(X) = E[X²] − (E[X])² is ∞ — the identity is formally correct but useless for error bars, and the CLT in its usual form fails.
- Conditionally convergent expectation. If E[|X|] = ∞ while the signed sum appears to converge, the term-by-term split in step 4 is a rearrangement of a conditionally convergent series and can yield any value; linearity genuinely fails.
- No joint law. If X and Y come from separate, uncoupled experiments, E[X+Y] is undefined until a joint distribution is imposed, so the linearity equation has no left-hand side.
Failure modes
- "Var(X+Y) = Var(X)+Var(Y)" reflex. True only when Cov(X,Y)=0. Students borrow the independence-free status of mean linearity and wrongly grant it to variance.
- Dropping the square on the constant. Writing Var(aX+b) = a Var(X) or, worse, Var(aX+b)=a²Var(X)+b. The constant contributes nothing and the multiplier is squared.
- Sign error in the computational form. Writing Var(X) = (E[X])² − E[X²], which is ≤ 0 — a guaranteed red flag since variance is non-negative.
- Confusing E[X²] with (E[X])². Squaring the mean of a dataset instead of averaging the squares; by Jensen these differ by exactly Var(X) ≥ 0.
- Assuming E[XY]=E[X]E[Y] to get linearity. Linearity of the mean needs no such factorisation; only products (and hence covariance) do.
- Using the identities when the mean/variance is undefined for a heavy-tailed sample, then trusting a spuriously finite sample statistic.
Discussion
The deepest fact here is operational: expectation is a linear functional on the space of integrable random variables, E: L¹ → ℝ. Steps 3–6 are nothing more than the statement that integration against a fixed measure is linear, and that is why no independence is needed — independence is a property of the joint measure, whereas linearity is a property of the integral. The two live at different levels, which is precisely why students who conflate them mis-apply the variance rule.
The identity Var(X) = E[X²] − (E[X])² is the probabilistic face of the parallel-axis structure: the second moment about any point c is E[(X−c)²] = Var(X) + (E[X]−c)², minimised at c = E[X]. The mean is thus the least-squares centre of the distribution, and the variance is the irreducible residual — the same decomposition that underlies moment of inertia in mechanics and the bias–variance split in statistics.
Linearity scales without limit: E[∑i Xi] = ∑i E[Xi] for any finite collection, dependent or not. This is the engine behind the mean of the binomial (a sum of n Bernoulli indicators gives np in one line), the expected number of fixed points of a random permutation (exactly 1, via indicators despite ferocious dependence), and the analysis of randomised algorithms.
Rigorously, expectation is the Lebesgue integral E[X] = ∫Ω X dP, and steps 4–5 are Fubini–Tonelli plus dominated convergence: absolute integrability (Tonelli on |X|) is exactly the hypothesis that licenses interchanging the order of summation/integration. The variance is then the squared L²-norm of the centred variable, Var(X) = ‖X − μ‖²2, and the identity Var(X)=E[X²]−μ² is the Pythagorean relation in L²(P) between X, its projection onto the constants (μ), and the residual — the constant subspace and the mean-zero subspace being orthogonal complements.
Common misconceptions. "Linearity of expectation requires independence" — false, it never does. "Variance adds like the mean" — false, it adds only up to 2Cov. "E[X²] = (E[X])²" — false in general; equality holds iff X is constant.
Worked examples
Reading. The die averages 3.5 with a spread of about 1.7 pips. Tripling and shifting the payout triples the average pip count and adds 2, while the variance grows nine-fold — the +2 is invisible to the spread.
Units check. With X in pips, Var is in pips² and σ back in pips; Var(Y) in (payout-unit)².
Reading. Two dice centre on 7 — the familiar peak of the sum — with a spread of about 2.4, larger than one die but only by √2 in standard deviation, not by 2.
Units check. Pips throughout; Var in pips², σ in pips.
Problems
- A Bernoulli variable takes value 1 with probability p and 0 otherwise. Find E[X] and Var(X).
Solution
E[X] = 1·p + 0·(1−p) = p. Since X² = X (values are 0 or 1), E[X²] = p, so Var(X) = p − p² = p(1−p). Maximal at p = 1/2 giving 1/4.
- Using linearity and problem 1, find the mean and variance of a Binomial(n,p) variable written as S = ∑i=1n Xi of independent Bernoullis.
Solution
E[S] = ∑ E[Xi] = np by linearity (no independence needed). For the variance, independence gives zero covariances, so Var(S) = ∑ Var(Xi) = n p(1−p). E.g. n=20, p=0.3: E[S]=6, Var(S)=20(0.3)(0.7)=4.2, σ≈2.05.
- Exam marks X have E[X] = 62, Var(X) = 144. The marks are rescaled by Y = 1.1X + 5. Find E[Y], Var(Y), and the standard deviation σY.
Solution
E[Y] = 1.1(62)+5 = 68.2+5 = 73.2. Var(Y) = (1.1)²(144) = 1.21×144 = 174.24. σY = 1.1×√144 = 1.1×12 = 13.2. The additive 5 leaves the spread untouched; only the 1.1 factor scales it.
- A continuous variable is uniform on [0, L] with density f(x) = 1/L. Derive E[X] and Var(X) from the integral definition.
Solution
E[X] = ∫0L x(1/L)dx = (1/L)(L²/2) = L/2. E[X²] = ∫0L x²(1/L)dx = (1/L)(L³/3) = L²/3. Then Var(X) = L²/3 − (L/2)² = L²/3 − L²/4 = L²/12. Standard deviation L/(2√3).
- Two variables have Var(X)=9, Var(Y)=16, and correlation ρ = 0.5. Find Var(X+Y) and Var(X−Y). Comment on why they differ.
Solution
Cov(X,Y) = ρ σXσY = 0.5×3×4 = 6. Then Var(X+Y) = 9+16+2(6) = 37 and Var(X−Y) = 9+16−2(6) = 13. Positive correlation means the two tend to move together, so their sum swings more and their difference less. This shows variance is not additive in general — only the mean is, by pure linearity.