QTQuant 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)

For a discrete random variable XX taking values xix_i with probabilities pip_i:

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

For a continuous random variable with density f(x)f(x):

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

Concrete examples:

Linearity (this is huge)

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

Always. No matter whether XX and YY are independent, correlated, anything. 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

where μ=E[X]\mu = E[X]. The square is important — it weights large deviations more than small ones.

Standard deviation is just the square root: σ=Var(X)\sigma = \sqrt{\text{Var}(X)}. Same information, but in the units of XX instead of X2X^2. For daily SPY returns, σ0.012\sigma \approx 0.012 (about 1.2% per day, or ~19% annualized).

Why squared, not absolute?

You might wonder: why measure spread with (Xμ)2(X - \mu)^2 instead of Xμ|X - \mu| (mean absolute deviation)? Three reasons:

  1. Mathematical convenience. The squared term is differentiable everywhere; the absolute value isn't. 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). Absolute deviations don't.

Modern quantitative work occasionally uses MAD or other robust scale measures, 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