Math Atom · M-D01

Estimating mean and volatility

8 minMath AtomStatistics

By the end you will be able to

  1. 1Tell a sample from the population it comes from, and an estimate from the true value.
  2. 2Calculate the sample mean, the sample variance (dividing by n − 1) and the sample standard deviation.
  3. 3Give an intuitive reason for dividing by n − 1.
  4. 4Explain why more data gives steadier estimates.

Why you need it

Nobody hands you the true volatility of a share. You have a list of past returns, and you work out an estimate from it. This atom is about that step: from the data you have to the number you want.

You met the formula in L1.5.06: Equity returns and volatility. Here it is explained piece by piece, along with why the answer wobbles.

The idea

You only ever see a sample

Picture a machine that produces daily returns. It has a true average, μ = 0.04%, and a true standard deviation, σ = 1%: that is the population. In real life those numbers are hidden. All you get is a sample of days. Draw a few and compare what you would estimate with the truth.

Draw a sample

Sample 1 · 10 illustrative daily returns
-3%-2%-1%0%1%2%3%x̄ ± s (this sample)μ ± σ (true)
Sample mean xˉ\bar x−0.168%
True mean μ0.04%
Sample sd s0.64%
True sd σ1%

Your last samples of 10

#xˉ\bar xs
1−0.168%0.64%

Every sample gives a slightly different answer. The sample mean and sample standard deviation are estimates: sensible guesses at μ and σ, never exactly right.

The rules

The sample mean. Greek letters (μ, σ) are the true values; letters from the data (x̄, s) are the estimates.

The sample variance and standard deviation. Spread is measured by squared deviations from the mean, as in M-C03: Variance and standard deviation, but with one change when you only have a sample.

Why n − 1? No proof needed, just the idea.

Check it with simulated samples. Small samples show the gap best.

Divide by n or by n − 1?

4,000 samples of size n, true variance 1
True variance σ²1
Average of s² dividing by n − 10.992
Average dividing by n0.661
Dividing by n falls short by33.9%

In theory, dividing by n gives on average (n − 1)/n of the true variance: 0.667 for n = 3. The shortfall matters most for small samples.

The rules, for reference

xˉ=1n∑i=1nxis2=1n−1∑i=1n(xi−xˉ)2s=s2\bar x = \frac{1}{n}\sum_{i=1}^{n} x_i \qquad s^2 = \frac{1}{n-1}\sum_{i=1}^{n}(x_i - \bar x)^2 \qquad s = \sqrt{s^2}

Divide by n − 1 whenever the standard deviation is estimated from a sample, as across the course. Divide by N only when you truly have the whole population and know μ.

Try it

Five analysts each estimate the same volatility from their own illustrative data. Slide the number of days from 2 up to 500 and watch the estimates settle. Press “New samples” a few times: the early estimates jump around, the late ones barely move.

Try itHow many days do you need?

Descriptive statistics calculator →
Each line is one analyst's estimate s (with n − 1) as more days come in. The dashed line is the true σ = 1%. Days are on a stretched scale so the early wobbles are visible.
0%0.5%1%1.5%2%25102050100200500days →

Analyst 1 (the thick line), first 20 days

Sample mean xˉ\bar x0.187%
Sample sd s0.84%
Error against the true σ−0.16%

All 5 analysts after 20 days

Lowest estimate0.84%
Highest estimate1.161%
Spread between them0.321%

Same process, same true σ, different samples: more days, steadier estimates.

Worked examples

1. Volatility from five days

Step 1 of 5
  1. 1

    The set-up

    Five daily returns, in % (illustrative): 1.4, −0.6, 0.7, −1.3, 0.8.

2. How much does n − 1 matter?

Step 1 of 3
  1. 1

    The set-up

    Dividing by n − 1 instead of n makes s bigger by a factor n/(n−1)\sqrt{n/(n-1)}. How big is that?

3. How steady is the estimate?

Step 1 of 3
  1. 1

    The set-up

    Simulate 2,000 analysts, each with their own sample from the same process (true σ = 1%), for three sample sizes. Look at the middle 90% of their estimates.

Common mistakes

Each line below is a tempting slip. Spot what is wrong, then check.

Reaction

Check what stuck

Question 1 · objective 2

What is the sample mean of 2, 4 and 9?

Question 2 · objective 2

What is the sample variance s² of 2, 4 and 9 (divide by n − 1)?

Question 3 · objective 2

What is the sample standard deviation s of 1 and 3, to three decimals?

Question 4 · objective 3

Why does the sample variance divide by n − 1 rather than n?

Question 5 · objective 4

Two analysts estimate the volatility of the same share, one from 20 days and one from 320 days. What do you expect?

Glossary

Population
Everything you would like to know about: every possible value, or the process that produces them. Its mean μ and standard deviation σ are the true values.
Sample
The values you actually have, such as the last n days of returns. Statistics are worked out from it.
Estimate
A number worked out from a sample to stand in for an unknown true value, such as x̄ for μ.
Sample mean (x̄)
x̄ = (x₁ + … + xₙ) / n: the ordinary average of the sample.
Sample variance (s²)
s² = Σ(xᵢ − x̄)² / (n − 1): the average squared deviation from the sample mean, dividing by n − 1.
Sample standard deviation (s)
s = √s²: the sample standard deviation, in the same units as the data. For returns, the volatility estimate.
Estimation error
The difference between an estimate and the true value. It shrinks, on average, as the sample grows.