Expected value and variance
▸ Pretest — guess, even if you don't know
A coin flip pays $1 if heads, $0 if tails. The flip is fair. What is the expected value of one flip?
Expected value (the first moment)
A "moment" is a summary number computed from a distribution — the mean is the first one, variance is built from the second. For a discrete random variable taking values with probabilities :
In words: multiply each possible value by its probability, then add them all up. It is a probability-weighted average — outcomes that are more likely count for more.
For a continuous random variable with density — the curve from A1-02 whose height says how thickly probability is packed near each value:
In words: the same weighted average, but over a smooth range of values instead of a list. The symbol is an integral — a running sum across the whole range. Read aloud: "E of X equals the integral of x times f of x, d x."
Concrete examples:
- Fair coin paying 0: .
- Daily SPY return historically: (about 7.5% annualized).
- An unfair die (face rolled with ): .
Linearity (this is huge)
In words: here and are ordinary fixed numbers, like 0.6 and 0.4. The expected value of "a times X plus b times Y" is just a times the expected value of X, plus b times the expected value of Y.
Concrete example: a portfolio is 60% asset X (expected return 8%) and 40% asset Y (expected return 4%). Its expected return is 0.6 × 8% + 0.4 × 4% = 6.4%. No further math needed.
This holds always. No matter whether and are independent, correlated — tending to move together — or anything else. Linearity of expectation is the most useful single fact in probability. It lets you compute expected portfolio returns as weighted sums of expected asset returns, even when the assets are correlated.
Variance (the second central moment)
The variance measures how spread out the distribution is:
In words: is read "the variance of X." Take each outcome's distance from the mean , square it, and take the probability-weighted average of those squared distances. The second form is the same quantity computed a different way: the average of X-squared, minus the square of the average.
Here — the expected value we just defined. The square is important: it weights large deviations more than small ones.
Concrete example — the fair coin paying 0: the mean is . The squared distances are and . So Var = 0.5 × 0.25 + 0.5 × 0.25 = 0.25.
Standard deviation is just the square root: . In words: sigma equals the square root of the variance. Same information, but in the units of instead of — so for returns, sigma is in return units, not squared-return units. For daily SPY returns, (about 1.2% per day, or ~19% annualized — scaled up to a per-year figure).
Why squared, not absolute?
You might wonder: why measure spread with instead of ? The vertical bars mean absolute value — the distance from the mean, ignoring sign. Averaging that instead gives the "mean absolute deviation" (MAD). Three reasons variance won:
- Mathematical convenience. The squared term is differentiable everywhere — smooth enough for calculus tools to work on. The absolute value isn't (it has a sharp corner at zero). Variance plays nicely with calculus.
- CLT alignment. Variance is the parameter the normal distribution is defined in terms of.
- Portfolio math. Variance of a sum decomposes nicely: . In words: the variance of a sum is each variance plus a correction term for co-movement. is read "the covariance of X and Y" — a number measuring how X and Y move together, positive when they tend to rise together. Absolute deviations don't decompose like this.
Modern quantitative work occasionally uses MAD or other robust scale measures — robust meaning not thrown off by a few outliers — but variance is the default.
Annualization (a tiny piece of magic)
For independent daily returns: (252 trading days per year). Standard deviation scales as :
This is the source of the famous "multiply daily volatility by ~16 to annualize" rule. Returns being roughly independent across days is what makes this work — and it's the first assumption that breaks under volatility clustering.
Higher moments (briefly)
Two more moments come up:
- Skewness — asymmetry, or lopsidedness. The formula is . In words: take each deviation from the mean, divide by sigma to put it in standard units, raise it to the third power, and take the probability-weighted average. The odd power keeps each deviation's sign, so a longer left (loss) tail drags the whole number negative. Negative skew means more weight in the left tail. Stock returns have slight negative skew.
- Kurtosis — tail heaviness: how common extreme outcomes are. Same recipe with the fourth power: . In words: average of the standardized deviations raised to the fourth power. The even power ignores sign and rewards big deviations enormously, so fat tails push kurtosis up. The normal distribution has kurtosis 3. Daily stock returns have kurtosis often 5–10 (fat tails again).
We'll see these explicitly when we discuss risk decomposition later in the curriculum.
The single most important fact for trading
For correlated assets, the variance of a sum is NOT the sum of variances.
If and are positively correlated (most stocks are with each other), portfolio variance is larger than the simple sum. If negatively correlated, smaller. This is the math underneath diversification — and it's why portfolio construction is interesting.
We'll come back to this in Track D3 (Portfolio theory). For now: linearity is universal; variance is not.
Try it
Compute the first two moments of a discrete distribution — probability-weighted, not sample statistics:
Implement expected_value(outcomes, probs) = sum of outcome * probability, and variance(outcomes, probs) = sum of probability * (outcome - E)**2. These are the population formulas for a discrete distribution — do NOT use np.mean or np.var, which assume equal weights.
⧉ Review cardWhat is the formula for expected value of a continuous random variable?
⧉ Review cardWhat is linearity of expectation?
⧉ Review cardWhy is variance defined as E[(X-μ)²], not E[|X-μ|]?
⧉ Review cardHow do you annualize daily volatility?
⧉ Review cardWhat is Var(X + Y) when X and Y are correlated?
Predict before the next track
Tomorrow we shift to statistics (Track A2) — applying these probability concepts to data. Predict:
- If you have 30 days of returns and want to estimate the true mean return, how confident should you be that your sample mean is close to the true mean?
- What about with 30 years of data?
◈ Calibration check
Could you compute the expected value and variance of a simple two-outcome bet?
1 = guessing · 5 = could teach it
⏻ End of lesson
Mark it read to book its 5 review cards into your deck.
Sources & further reading
- bookWasserman (2004), All of Statistics — §3
- bookRoss (2014), Introduction to Probability Models, 11e — §2.3, 2.4
- bookTsay (2010), Analysis of Financial Time Series, 3e — §1.2