Quant Terminal
A1-04A1·intro·~17 min

Expected value and variance

probabilityexpected-valuevariancemoments

▸ 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 XX taking values xix_i with probabilities pip_i:

E[X]=ixipiE[X] = \sum_i x_i \, p_i

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 f(x)f(x) — the curve from A1-02 whose height says how thickly probability is packed near each value:

E[X]=xf(x)dxE[X] = \int x \, f(x) \, dx

In words: the same weighted average, but over a smooth range of values instead of a list. The \int 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:

Linearity (this is huge)

E[aX+bY]=aE[X]+bE[Y]E[aX + bY] = aE[X] + bE[Y]

In words: here aa and bb 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 XX and YY 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:

Var(X)=E[(Xμ)2]=E[X2]μ2\text{Var}(X) = E[(X - \mu)^2] = E[X^2] - \mu^2

In words: Var(X)\text{Var}(X) is read "the variance of X." Take each outcome's distance from the mean μ\mu, 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 μ=E[X]\mu = E[X] — the expected value we just defined. The square is important: it weights large deviations more than small ones.

Concrete example — the fair coin paying 1or1 or 0: the mean is μ=0.5\mu = 0.5. The squared distances are (10.5)2=0.25(1 - 0.5)^2 = 0.25 and (00.5)2=0.25(0 - 0.5)^2 = 0.25. So Var = 0.5 × 0.25 + 0.5 × 0.25 = 0.25.

Standard deviation is just the square root: σ=Var(X)\sigma = \sqrt{\text{Var}(X)}. In words: sigma equals the square root of the variance. Same information, but in the units of XX instead of X2X^2 — so for returns, sigma is in return units, not squared-return units. For daily SPY returns, σ0.012\sigma \approx 0.012 (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 (Xμ)2(X - \mu)^2 instead of Xμ|X - \mu|? 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:

  1. 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.
  2. CLT alignment. Variance is the parameter the normal distribution is defined in terms of.
  3. Portfolio math. Variance of a sum decomposes nicely: Var(X+Y)=Var(X)+Var(Y)+2Cov(X,Y)\text{Var}(X + Y) = \text{Var}(X) + \text{Var}(Y) + 2\text{Cov}(X, Y). In words: the variance of a sum is each variance plus a correction term for co-movement. Cov(X,Y)\text{Cov}(X, Y) 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: Var(annual)252Var(daily)\text{Var}(\text{annual}) \approx 252 \cdot \text{Var}(\text{daily}) (252 trading days per year). Standard deviation scales as 25215.87\sqrt{252} \approx 15.87:

σannual15.87σdaily\sigma_{\text{annual}} \approx 15.87 \cdot \sigma_{\text{daily}}

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:

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.

Var(X+Y)=Var(X)+Var(Y)+2Cov(X,Y)\text{Var}(X + Y) = \text{Var}(X) + \text{Var}(Y) + 2\text{Cov}(X, Y)

If XX and YY 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:

▮ EXERCISE · a1-04-ex1

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 card
What is the formula for expected value of a continuous random variable?
E[X] = ∫ x f(x) dx, where f(x) is the density. For discrete: E[X] = Σ x_i p_i.
⧉ Review card
What is linearity of expectation?
E[aX + bY] = aE[X] + bE[Y] — always, regardless of independence or correlation of X and Y. The single most useful identity in probability.
⧉ Review card
Why is variance defined as E[(X-μ)²], not E[|X-μ|]?
Mathematical convenience (differentiable), CLT alignment (normal is defined by variance), and clean decomposition for sums (Var(X+Y) = Var(X) + Var(Y) + 2Cov(X,Y)).
⧉ Review card
How do you annualize daily volatility?
Multiply by √252 ≈ 15.87 (252 trading days/year). Var annualizes linearly; std dev as the square root. Assumes independence across days.
⧉ Review card
What is Var(X + Y) when X and Y are correlated?
Var(X) + Var(Y) + 2Cov(X,Y). The 2Cov term is what makes diversification non-trivial — uncorrelated assets reduce portfolio variance, correlated ones don't.

Predict before the next track

Tomorrow we shift to statistics (Track A2) — applying these probability concepts to data. Predict:

◈ 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