Sub topic 2
Measuring Risk: Variance and Standard Deviation
This chapter assumes you know the mean, the idea of a squared deviation, the time value of money, and the difference between a population and a sample. It builds on the return measures from the previous chapter. Here you will learn how to turn a set of possible or past returns into one number for risk.
Why risk needs a number
Two investments can both have an expected return of 8%. If one almost always returns between 7% and 9% and the other swings between -20% and +35%, they are not equal. Portfolio theory measures this spread of outcomes around the expected value.
The CFA curriculum uses variance and standard deviation as its main measures of total risk. Everything later in this tutorial depends on them: covariance, portfolio risk, the efficient frontier, beta, and the Sharpe ratio.
Variance and standard deviation
Variance is the average squared distance of returns from their mean. Standard deviation is the square root of variance. The two measures carry the same information. Standard deviation is easier to read because it is in the same units as returns (percent), while variance is in percent squared.
You use one of two formulas, depending on where the data comes from.
Case 1: probability-weighted scenarios (forward-looking)
You have a list of possible outcomes, each with a probability. The variance is the probability-weighted average of squared deviations from the expected return:
- Expected return: E[R] = Σ pᵢ × Rᵢ
- Variance: σ² = Σ pᵢ × (Rᵢ − E[R])²
- Standard deviation: σ = √σ²
Probabilities already do the averaging, so there is no division by n or n−1.
Worked example. An asset has three scenarios:
| Scenario | Probability | Return |
|---|---|---|
| Boom | 0.25 | 20% |
| Normal | 0.50 | 8% |
| Recession | 0.25 | -4% |
- E[R] = 0.25(0.20) + 0.50(0.08) + 0.25(−0.04) = 0.05 + 0.04 − 0.01 = 0.08, or 8%.
- Squared deviations: (0.20 − 0.08)² = 0.0144, (0.08 − 0.08)² = 0, and (−0.04 − 0.08)² = 0.0144.
- Variance = 0.25(0.0144) + 0.50(0) + 0.25(0.0144) = 0.0072.
- Standard deviation = √0.0072 = 0.0849, or 8.49%.
Case 2: historical returns (a sample)
You have n past returns and want to estimate the underlying variance. The CFA formula for the sample variance is:
- Mean: R̄ = (Σ Rᵢ) / n
- Sample variance: s² = Σ (Rᵢ − R̄)² / (n − 1)
- Sample standard deviation: s = √s²
Dividing by n − 1 instead of n corrects a bias. Deviations are measured from the sample mean, which sits closer to the sample's own data than the true mean does. That makes deviations look too small, and the smaller divisor compensates.
Worked example. Five annual returns: 10%, −5%, 12%, 7%, 6%.
- Mean = 30% / 5 = 6%.
- Deviations in percentage points: 4, −11, 6, 1, 0. Squared: 16, 121, 36, 1, 0. The sum is 174.
- Sample variance = 174 / 4 = 43.5 (%²), or 0.00435 in decimals.
- Sample standard deviation = √43.5 = 6.60%.
Using n instead would give 174 / 5 = 34.8 and a standard deviation of 5.90%. That is the population formula, and it is wrong when your data is only a sample.
Computing both in code
The functions below implement the two formulas. They reproduce the numbers worked by hand above.
from math import sqrt
def scenario_stats(probs, returns):
"""Expected return, variance, and sd for probability-weighted scenarios."""
if abs(sum(probs) - 1) > 1e-9:
raise ValueError("probabilities must sum to 1")
mean = sum(p * r for p, r in zip(probs, returns))
var = sum(p * (r - mean) ** 2 for p, r in zip(probs, returns))
return mean, var, sqrt(var)
def sample_stats(returns):
"""Mean, sample variance (n - 1), and sample sd for historical returns."""
n = len(returns)
mean = sum(returns) / n
var = sum((r - mean) ** 2 for r in returns) / (n - 1)
return mean, var, sqrt(var)
mean, var, sd = scenario_stats([0.25, 0.50, 0.25], [0.20, 0.08, -0.04])
print(f"Scenarios: E[R]={mean:.2%} variance={var:.5f} sd={sd:.2%}")
mean, var, sd = sample_stats([0.10, -0.05, 0.12, 0.07, 0.06])
print(f"History: mean={mean:.2%} variance={var:.5f} sd={sd:.2%}")The output is:
Scenarios: E[R]=8.00% variance=0.00720 sd=8.49%
History: mean=6.00% variance=0.00435 sd=6.60%Annualizing risk
Return data often comes monthly or weekly, but risk is usually quoted per year. If returns in different periods are independent and have the same variance, then variance grows in proportion to time. Standard deviation grows with the square root of time.
- σannual² = 12 × σmonthly²
- σannual = σmonthly × √12
For a monthly standard deviation of 3%, the annual figure is 3% × √12 = 10.39%.
| Data frequency | Periods per year | Multiply sd by |
|---|---|---|
| Monthly | 12 | √12 ≈ 3.464 |
| Weekly | 52 | √52 ≈ 7.211 |
| Daily (trading days) | 252 | √252 ≈ 15.875 |
from math import sqrt
monthly_sd = 0.03
annual_sd = monthly_sd * sqrt(12)
print(f"Annual sd: {annual_sd:.2%}") # Annual sd: 10.39%The square-root rule relies on independence across periods. If returns are positively autocorrelated, as in smoothed real-estate or private-equity valuations, the rule understates true annual risk.
Comparing risk across assets
Standard deviation answers "how much does this asset vary?" It does not answer "how much risk per unit of return?" The coefficient of variation does that: CV = σ / E[R].
For the scenario asset above, CV = 8.49% / 8% = 1.06. A second asset with E[R] = 12% and σ = 15% has CV = 1.25. The first asset takes less risk per unit of expected return, even though its return is lower. Later chapters develop the Sharpe ratio, which refines this idea by subtracting the risk-free rate.
Edge cases and limitations
- Symmetry. Variance counts upside surprises as risk just like downside ones. Investors usually dislike only the downside. Measures such as semivariance and downside deviation address this, but the Level I curriculum relies mainly on standard deviation.
- Normality. Standard deviation fully describes risk only if returns are roughly normally distributed. Real returns often have fat tails (extreme losses more frequent than the normal curve predicts) and skewness. Two assets can share the same standard deviation and have very different tail risk.
- Sample size. A sample standard deviation from five years of data is a noisy estimate. The estimate also changes depending on which period you choose.
- Units. A variance of 0.0072 and a standard deviation of 8.49% describe the same risk. Keep decimals and percentages consistent. Mixing 43.5 (%²) with 0.00435 (decimal²) is a common source of arithmetic errors.
- Arithmetic versus geometric mean. Deviations in the variance formula are measured from the arithmetic mean, not the geometric mean.
Common errors
- Using n instead of n − 1 for historical samples.
- Dividing by n (or n − 1) in the scenario formula. Probabilities already provide the weights.
- Forgetting to take the square root, so the answer is a variance when a standard deviation was asked for.
- Scaling standard deviation linearly with time.
- Reporting variance in percent when the formula was computed in decimals, or the reverse.
Exercises
Exercise
A stock has a monthly return standard deviation of 4%. Assuming independent monthly returns, what is its annualized standard deviation and its annualized variance?
Show answer
Annual sd = 4% × √12 = 13.86%. Annual variance = 12 × (0.04)² = 12 × 0.0016 = 0.0192. As a check, √0.0192 = 0.1386.
Exercise
An asset has a 40% chance of returning 15%, a 40% chance of returning 5%, and a 20% chance of returning -10%. Find the expected return, variance, and standard deviation.
Show answer
E[R] = 0.4(0.15) + 0.4(0.05) + 0.2(−0.10) = 0.06 + 0.02 − 0.02 = 0.06, or 6%. Squared deviations: (0.15 − 0.06)² = 0.0081, (0.05 − 0.06)² = 0.0001, (−0.10 − 0.06)² = 0.0256. Variance = 0.4(0.0081) + 0.4(0.0001) + 0.2(0.0256) = 0.00324 + 0.00004 + 0.00512 = 0.0084. Standard deviation = √0.0084 = 9.17%.
Exercise
Four quarterly returns are 3%, 5%, -2%, and 6%. Calculate the sample standard deviation, and explain why dividing by n would give a smaller value.
Show answer
Mean = 12% / 4 = 3%. Deviations: 0, 2, −5, 3. Squared: 0, 4, 25, 9, summing to 38. Sample variance = 38 / 3 = 12.67 (%²), so the sample sd = √12.67 = 3.56%. Dividing by n = 4 gives 9.5 and an sd of 3.08%. That is smaller because the sample mean is fitted to the same data, which makes the deviations look smaller than deviations from the true mean. The n − 1 divisor corrects for this.