20 — Volatility

Standard Deviation#

Statistical1 min read
◆ The PatternHow widely values spread around their mean, the single number most of risk measurement is built on

Standard Deviation — the statistical building block of volatility measurement.

σ = √(Σ(x − μ)² / N)
where μ = mean, N = number of observations

Higher σ = more volatility = prices are spread far from the mean.

In markets:
• Historical Volatility = σ of returns × √252 (annualized)
• For normal data, 1σ covers ~68% and 2σ ~95% → the basis of Bollinger Bands
• 3σ events are "rare" but happen more often in markets than normal distributions predict (fat tails)
Worked example

Day 15: the last five closes (104, 102, 99, 101, 104) average 102.0. The deviations are 2, 0, −3, −1 and 2; squared, 4, 0, 9, 1 and 4; their mean is 3.6, and its square root 1.90. Measured on daily returns instead of prices it is about 2.6% a day — returns are what risk models use.

The example data: 15 days, used in every indicator here
DayHighLowCloseVolume
11019910050,000
210310010262,000
310310010148,000
410510110470,000
510810410785,000
610810510660,000
711010610990,000
811010710872,000
910810410580,000
1010510210366,000
1110510210455,000
1210410110275,000
13102989995,000
141029910164,000
1510510110471,000
Where it misleads
  • It treats moves up and down alike, so a sharp rally counts as “risk” the same as a fall.
  • It assumes the spread is stable. Volatility clusters, so after a calm spell yesterday’s figure understates tomorrow’s.
  • Returns have fat tails: extreme days come far more often than a bell curve with this standard deviation predicts.
In code
df['sd5'] = df['close'].rolling(5).std(ddof=0)
df['ret_sd5'] = df['close'].pct_change().rolling(5).std()   # the same idea on returns
Python, in your browser — edit the code and run it again

Assumes import numpy as np, import pandas as pd, and a DataFrame df with columns high, low, close and volume — the 15 days above.

Sources
  • B. Mandelbrot, “The Variation of Certain Speculative Prices”, Journal of Business 36(4), 1963 — fat tails in prices
  • J. C. Hull, Options, Futures, and Other Derivatives, Pearson — estimating volatility from returns

Last reviewed October 2026 · How this site checks its content · Report a mistake

Pattern bridge: This is standard deviation from statistics, applied to price returns. In ML, it’s the denominator in batch normalization and the width of Gaussian distributions.
Linked from 12
← Previous
Donchian Channels
Open in the full reader, with the topic sidebar