Quant Memo
Core

Weighted Mean and Weighted Variance

When observations don't all carry equal importance — bigger positions, more reliable estimates, more recent data — the mean and variance formulas need weights folded in, and the variance formula in particular changes in a way that trips people up.

Prerequisites: Standard Deviation, Weighted Averages and Mixture Shortcuts

A portfolio holds three positions of very different sizes: $10,000, $50,000, and $940,000, with returns of +8%, +3%, and +1% respectively. What was the portfolio's return? Averaging the three percentages plainly gives (8+3+1)/3=4%(8+3+1)/3 = 4\%, but that treats the tiny $10,000 position as equally important as the $940,000 position — obviously wrong. The weighted mean fixes this by letting each observation contribute in proportion to its importance, and the weighted variance does the analogous fix for measuring spread, though it has a subtlety that catches people out: dividing by the wrong thing at the end.

An analogy: a class grade from unequal assignments

Imagine a course grade built from a quiz (5% of the grade), a midterm (35%), and a final exam (60%). You wouldn't average the three scores equally — a student who aces the quiz and bombs the final should still fail the course. You multiply each score by its weight and add them up. Weighted mean and weighted variance apply the identical idea to any set of numbers where some observations should simply count for more: bigger dollar positions, more reliable (lower-noise) estimates, or more recent data points in a time-decayed average.

The mechanics, one piece at a time

The weighted mean of values xix_i with weights wiw_i is

xˉw=iwixiiwi.\bar{x}_w = \frac{\sum_i w_i x_i}{\sum_i w_i}.

In plain English: multiply each value by its weight, add those up, then divide by the total weight (not by the count nn) — this rescaling is what makes weights that don't sum to 1 work correctly. The weighted variance measures how spread out the values are around that weighted mean, but weighted by the same wiw_i:

sw2=iwi(xixˉw)2iwi.s_w^2 = \frac{\sum_i w_i (x_i - \bar{x}_w)^2}{\sum_i w_i}.

In plain English: for each observation, square its distance from the weighted mean, scale that squared distance by its weight, and again divide by total weight rather than count. The subtlety: when weights represent a sample (as opposed to full population weights or known reliability weights), the simple divide-by-total-weight formula is biased, and a correction factor is needed for an unbiased variance estimate — this is the detail that trips people up, discussed below.

Worked example 1: the portfolio return, weighted correctly

Using the position sizes as weights: total capital is $1,000,000. Weighted mean return =10,000×0.08+50,000×0.03+940,000×0.011,000,000=800+1,500+9,4001,000,000=11,7001,000,000=1.17%= \frac{10{,}000 \times 0.08 + 50{,}000 \times 0.03 + 940{,}000 \times 0.01}{1{,}000{,}000} = \frac{800 + 1{,}500 + 9{,}400}{1{,}000{,}000} = \frac{11{,}700}{1{,}000{,}000} = 1.17\%. This is far closer to the 1% return of the dominant $940,000 position than the naive unweighted average of 4% — because that position is 94% of the portfolio, its return should dominate the answer, and the weighted mean correctly reflects that.

Worked example 2: weighted variance of analyst forecasts

Three analysts forecast next quarter's EPS as $1.00, $1.20, and $1.50, but you trust them unequally, with reliability weights 0.5, 0.3, and 0.2 (summing to 1, so total weight is 1). Weighted mean: 0.5(1.00)+0.3(1.20)+0.2(1.50)=0.50+0.36+0.30=1.160.5(1.00) + 0.3(1.20) + 0.2(1.50) = 0.50 + 0.36 + 0.30 = 1.16, i.e. $1.16. Weighted variance: 0.5(1.001.16)2+0.3(1.201.16)2+0.2(1.501.16)2=0.5(0.0256)+0.3(0.0016)+0.2(0.1156)=0.0128+0.00048+0.02312=0.03640.5(1.00-1.16)^2 + 0.3(1.20-1.16)^2 + 0.2(1.50-1.16)^2 = 0.5(0.0256) + 0.3(0.0016) + 0.2(0.1156) = 0.0128 + 0.00048 + 0.02312 = 0.0364, so the weighted standard deviation is 0.03640.191\sqrt{0.0364} \approx 0.191, i.e. about $0.191. Compare this to the unweighted variance of the raw three numbers (about 0.043) — weighting shifts both the center (toward the more-trusted $1.00 forecast) and the measured spread, since deviations are now measured from a different, weight-adjusted center.

\$10k, +8% \$50k, +3% \$940k, +1% weighted average return ≈ 1.17%, not the naive 4%
The dominant \$940,000 position (bar width shows dollar weight) pulls the weighted average return down close to its own 1%, far from the unweighted average of the three percentages.
unweighted mean \$1.23 weighted mean \$1.16 unweighted sd ≈\$0.21 weighted sd \$0.191
Weighting by analyst reliability shifts both the center (toward the more-trusted forecast) and the measured spread, since every deviation is now computed from a different, weight-adjusted mean.

What this means in practice

Weighted means and variances are everywhere in portfolio math: benchmark-relative returns, factor exposures aggregated across holdings, and volatility estimates that exponentially downweight older observations (EWMA volatility is a weighted variance with time-decaying weights). Getting the weights wrong — or forgetting to weight at all — is one of the most common silent errors in performance reporting, because an unweighted average of percentage returns across positions of wildly different sizes is almost never the number anyone actually wants.

A weighted mean rescales each value by its importance and divides by total weight, not by count; a weighted variance does the same for squared deviations from that weighted mean — using dollar size, reliability, or recency as the weight turns a misleading equal-weighted summary into one that reflects what actually matters.

When weights come from a sample meant to represent a larger reliability structure (not fixed population weights), dividing by wi\sum w_i alone gives a biased variance estimate — the standard fix divides by wiwi2wi\sum w_i - \frac{\sum w_i^2}{\sum w_i} instead (the weighted analogue of dividing by n1n-1). Software defaults differ on this silently, so a "weighted standard deviation" from two different libraries applied to the same data and weights can legitimately disagree — always check which convention a function uses before comparing results across tools.

Related concepts

Practice in interviews

Further reading

  • Casella & Berger, Statistical Inference, ch. 5
ShareTwitterLinkedIn