Mean and standard deviation: return and risk in two numbers

On this page
  1. First: daily returns
  2. The mean: where the middle is
  3. The standard deviation: how far things stray
  4. 2020 to 2025, five tickers
  5. Same mean, different risk
  6. From daily to yearly: why 252\sqrt${252}252​
  7. The 68–95–99.7 rule, and why markets break it
  8. The code
  9. Summary
  10. References

Any analysis of returns starts with these two numbers. Almost every measure of a fund or strategy, including the Sharpe ratio, is built from them. The expected value post ended with “two choices can have the same average and very different risk”. This post measures that difference.

First: daily returns

In finance we rarely work with prices directly. We work with returns: the percentage change from one day to the next. This is the definition in Romero and Balch’s What Hedge Funds Really Do (chapter 2), with the symbols in Table 1:

returns, the datathe meanthe spread: standard deviation, variance

rt=ptpt−1−1\good{r_t} = \frac{p_t}{p_{t-1}} - 1
Table 1. Symbols in the daily return formula
SymbolMeaning
ptp_tprice on day tt
pt−1p_{t-1}price on the day before
rt\good{r_t}return on day tt

On the first trading day of 2020, SPY (the S&P 500 fund) closed at $295.39, and the next day at $293.15: r=293.15/295.39−1=−0.0076=−0.8%r = 293.15/295.39 - 1 = -0.0076 = \good{-0.8\%}. Returns let you compare a $10 stock with a $1,000 stock on the same scale. The examples below use daily closes for five tickers: SPY, NVDA, GS, XOM and GLD (gold), 2020 to 2025, adjusted for dividends and splits.

Daily returns compound: to get the return over many days, multiply one plus each day’s return together and subtract one (same chapter):

cumulative return=∏t=1n(1+rt)−1\text{cumulative return} = \prod_{t=1}^{n} (1 + \good{r_t}) - 1

Read ∏\prod as “multiply together”, the way ∑\sum means “add together”. That’s why the two funds further down end the year at different values despite the same average day, and why $100 in NVDA became $3,391 over 2020 to 2025 while the same $100 in XOM became $211.

The mean: where the middle is

Plain meaning: add everything up, divide by how many there are.

rˉ=1n∑t=1nrt\key{\bar{r}} = \frac{1}{n} \sum_{t=1}^{n} \good{r_t}

SPY’s first five daily returns of 2020, rounded to one decimal: −0.8%, 0.4%, −0.3%, 0.5%, 0.7%.

rˉ=−0.8+0.4−0.3+0.5+0.75=0.55=0.10%\key{\bar{r}} = \frac{-0.8 + 0.4 - 0.3 + 0.5 + 0.7}{5} = \frac{0.5}{5} = 0.10\%

On an average day that week, SPY made 0.10%\key{0.10\%}. (A good week: the average daily return over 2020 to 2025 is 0.065%.)

The standard deviation: how far things stray

Plain meaning: how far, typically, a day’s return lands from the average.

The recipe:

  1. For each day, find how far it is from the mean (the deviation).
  2. Square each deviation, so negatives don’t cancel positives.
  3. Average the squares. This is the variance.
  4. Take the square root, to get back to the original units (percent). This is the standard deviation.
s=1n−1∑t=1n(rt−rˉ)2\risk{s} = \sqrt{\frac{1}{n-1} \sum_{t=1}^{n} \left( \good{r_t} - \key{\bar{r}} \right)^2}

Worked out for the five days in Table 2 (mean 0.10%):

Table 2. Deviations and squared deviations for five SPY days, January 2020
DayReturn rt\good{r_t} (%)Deviation rt−rˉ\good{r_t} - \key{\bar{r}}Squared
1−0.8−0.90.81
20.40.30.09
3−0.3−0.40.16
40.50.40.16
50.70.60.36
Sum1.58
s2=1.585−1\risk{s^2} = \frac{1.58}{5 - 1} s2=0.395\risk{s^2} = 0.395 s=0.395\risk{s} = \sqrt{0.395} s=0.63%\risk{s} = 0.63\%

A typical day that week landed about 0.6 percentage points away from the 0.10% average. Over the whole of 2020 to 2025 SPY’s daily standard deviation is 1.32%; that first week of January 2020 was half as jumpy as normal, two months before the Covid crash tripled it.

Why divide by n−1n - 1, not nn?

This question comes up every time. When you compute the deviations, you measure them from the sample’s own mean, which is pulled towards the data you happen to have. So the deviations come out a little too small on average. Bishop and Bishop’s Deep Learning: Foundations and Concepts shows exactly how much (equation 2.60): the divide-by-nn variance comes out, on average, at

E[σML2]=n−1n σ2E\left[\risk{\sigma^2_{\text{ML}}}\right] = \frac{n-1}{n}\,\risk{\sigma^2}

of the true variance σ2\risk{\sigma^2}. Multiplying by n/(n−1)n/(n-1) undoes that, which is the same as dividing by n−1n - 1 instead of nn (their equation 2.63). It’s called Bessel’s correction, and the result is the sample standard deviation.

Dividing by nn gives the population standard deviation, which is right only when you have every possible value, not a sample. With years of daily data the two versions are practically equal. For the five days above: 0.63% (sample) versus 0.56% (population). With a year of daily data the difference is tiny, but with five days it’s large.

A practical trap: NumPy’s np.std divides by nn by default. Pandas’ .std() divides by n−1n - 1. Use np.std(x, ddof=1) to get the sample version in NumPy.

2020 to 2025, five tickers

Table 3 has the same two numbers for each ticker over 2020 to 2025, daily and then annualised (the next section explains the 252 and the square root):

Table 3. Mean and standard deviation by ticker, daily and annualised, 2020 to 2025
TickerAverage daily returnDaily standard deviationAnnual returnAnnual standard deviation$100 became
SPY0.065%1.32%16.4%20.9%$228
NVDA0.297%3.37%74.9%53.6%$3,391
GS0.114%2.08%28.7%33.0%$387
XOM0.073%2.09%18.3%33.1%$211
GLD0.069%1.03%17.5%16.3%$256

Two things to notice. Gold is the calm one: the smallest spread, and a better average day than SPY. And XOM earned a better average day than SPY, 0.073% against 0.065%, yet ended at $211 against SPY’s $228; XOM’s swings, about one and a half times SPY’s, cost it more than that edge was worth, which is the next section’s point.

Same mean, different risk

To isolate that point I made up two funds with exactly the same average daily return, 0.04%, but different standard deviations: 0.5% for the calm one, 1.5% for the wild one. Figure 1 draws a year of each.

{"panels":[{"x0":49.4,"x1":565.2,"y0":29.16,"y1":223.28,"title":"1. Two made-up funds with the same average daily return (0.04%)","xlabel":"Trading day of the year (1\u2013252)","ylabel":"Value of $100 invested ($)","xlog":false},{"x0":49.4,"x1":565.2,"y0":311.96,"y1":506.08,"title":"2. The same two funds: very different spread of daily returns","xlabel":"Daily return (%)","ylabel":"Number of days (of 252)","xlog":false}],"series":[{"panel":0,"label":"wild fund","color":"var(--chart-grey, #a3a19c)","kind":"line","x":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.0,11.0,12.0,13.0,14.0,15.0,16.0,17.0,18.0,19.0,20.0,21.0,22.0,23.0,24.0,25.0,26.0,27.0,28.0,29.0,30.0,31.0,32.0,33.0,34.0,35.0,36.0,37.0,38.0,39.0,40.0,41.0,42.0,43.0,44.0,45.0,46.0,47.0,48.0,49.0,50.0,51.0,52.0,53.0,54.0,55.0,56.0,57.0,58.0,59.0,60.0,61.0,62.0,63.0,64.0,65.0,66.0,67.0,68.0,69.0,70.0,71.0,72.0,73.0,74.0,75.0,76.0,77.0,78.0,79.0,80.0,81.0,82.0,83.0,84.0,85.0,86.0,87.0,88.0,89.0,90.0,91.0,92.0,93.0,94.0,95.0,96.0,97.0,98.0,99.0,100.0,101.0,102.0,103.0,104.0,105.0,106.0,107.0,108.0,109.0,110.0,111.0,112.0,113.0,114.0,115.0,116.0,117.0,118.0,119.0,120.0,121.0,122.0,123.0,124.0,125.0,126.0,127.0,128.0,129.0,130.0,131.0,132.0,133.0,134.0,135.0,136.0,137.0,138.0,139.0,140.0,141.0,142.0,143.0,144.0,145.0,146.0,147.0,148.0,149.0,150.0,151.0,152.0,153.0,154.0,155.0,156.0,157.0,158.0,159.0,160.0,161.0,162.0,163.0,164.0,165.0,166.0,167.0,168.0,169.0,170.0,171.0,172.0,173.0,174.0,175.0,176.0,177.0,178.0,179.0,180.0,181.0,182.0,183.0,184.0,185.0,186.0,187.0,188.0,189.0,190.0,191.0,192.0,193.0,194.0,195.0,196.0,197.0,198.0,199.0,200.0,201.0,202.0,203.0,204.0,205.0,206.0,207.0,208.0,209.0,210.0,211.0,212.0,213.0,214.0,215.0,216.0,217.0,218.0,219.0,220.0,221.0,222.0,223.0,224.0,225.0,226.0,227.0,228.0,229.0,230.0,231.0,232.0,233.0,234.0,235.0,236.0,237.0,238.0,239.0,240.0,241.0,242.0,243.0,244.0,245.0,246.0,247.0,248.0,249.0,250.0,251.0],"y":[103.342,102.378,103.408,103.531,104.38,102.382,105.006,104.681,104.605,102.987,101.716,102.461,103.87,104.929,106.727,107.753,107.665,108.899,109.746,109.441,110.512,112.534,112.795,112.043,113.127,116.255,115.738,115.43,115.047,117.042,113.627,114.117,116.043,114.463,116.911,117.716,116.586,116.803,113.932,112.81,115.802,114.084,117.14,116.849,118.47,118.401,114.218,113.081,113.266,111.143,108.727,109.197,107.982,105.063,103.839,105.068,104.18,105.531,107.849,107.768,105.782,103.557,103.386,104.642,104.939,105.681,104.836,105.184,104.299,103.652,101.487,98.9342,98.0857,96.3115,94.7874,95.636,95.3608,99.4662,100.743,99.6471,100.701,101.122,99.9411,101.491,100.168,95.3858,96.4181,95.3929,97.4287,96.3447,94.494,96.6004,94.9002,95.0751,97.0516,97.0993,96.859,96.8888,98.0036,96.6791,97.4558,98.1889,101.548,100.902,99.3725,100.36,99.6284,99.9418,100.018,101.67,100.528,100.261,96.2457,94.8231,96.9193,95.794,94.6528,92.782,93.4839,93.62,91.8139,92.6307,92.8813,93.8299,92.7976,95.1336,95.6075,95.3181,94.4472,93.9776,95.0871,94.5795,96.0115,96.7391,98.5984,99.6955,99.4755,96.4638,96.7811,97.8211,97.9412,98.6473,97.8167,97.1287,95.6158,97.476,97.5889,96.7363,94.6567,94.3179,96.2685,96.8242,95.6368,97.5956,99.5931,100.954,102.038,103.703,104.43,105.53,104.147,106.391,106.632,109.78,106.234,107.241,108.707,108.004,108.612,109.712,110.538,109.493,109.12,110.674,112.685,112.714,112.705,112.908,114.548,112.569,110.154,110.224,108.232,107.131,107.138,107.79,105.898,107.057,104.036,104.769,102.125,100.018,100.869,100.12,98.7841,97.9928,98.5631,98.3589,98.1921,99.6439,98.4342,97.605,96.7078,98.3055,99.6643,101.49,101.311,100.943,102.125,101.385,102.539,103.54,102.311,102.054,101.742,104.295,108.268,107.968,107.857,103.981,104.185,104.044,102.217,103.31,100.722,100.267,100.353,98.3224,99.4801,100.952,98.6982,96.4625,97.2252,97.0586,95.1499,94.6039,94.3311,94.0081,95.0732,95.5097,97.9596,99.8839,100.789,102.314,104.245,105.234,103.141,104.36,104.344,106.781,106.8,107.52],"sx":[72.85,74.72,76.58,78.45,80.32,82.19,84.06,85.92,87.79,89.66,91.53,93.4,95.27,97.13,99.0,100.87,102.74,104.61,106.47,108.34,110.21,112.08,113.95,115.82,117.68,119.55,121.42,123.29,125.16,127.02,128.89,130.76,132.63,134.5,136.36,138.23,140.1,141.97,143.84,145.71,147.57,149.44,151.31,153.18,155.05,156.91,158.78,160.65,162.52,164.39,166.26,168.12,169.99,171.86,173.73,175.6,177.46,179.33,181.2,183.07,184.94,186.81,188.67,190.54,192.41,194.28,196.15,198.01,199.88,201.75,203.62,205.49,207.35,209.22,211.09,212.96,214.83,216.7,218.56,220.43,222.3,224.17,226.04,227.9,229.77,231.64,233.51,235.38,237.25,239.11,240.98,242.85,244.72,246.59,248.45,250.32,252.19,254.06,255.93,257.8,259.66,261.53,263.4,265.27,267.14,269.0,270.87,272.74,274.61,276.48,278.34,280.21,282.08,283.95,285.82,287.69,289.55,291.42,293.29,295.16,297.03,298.89,300.76,302.63,304.5,306.37,308.24,310.1,311.97,313.84,315.71,317.58,319.44,321.31,323.18,325.05,326.92,328.78,330.65,332.52,334.39,336.26,338.13,339.99,341.86,343.73,345.6,347.47,349.33,351.2,353.07,354.94,356.81,358.68,360.54,362.41,364.28,366.15,368.02,369.88,371.75,373.62,375.49,377.36,379.23,381.09,382.96,384.83,386.7,388.57,390.43,392.3,394.17,396.04,397.91,399.77,401.64,403.51,405.38,407.25,409.12,410.98,412.85,414.72,416.59,418.46,420.32,422.19,424.06,425.93,427.8,429.67,431.53,433.4,435.27,437.14,439.01,440.87,442.74,444.61,446.48,448.35,450.22,452.08,453.95,455.82,457.69,459.56,461.42,463.29,465.16,467.03,468.9,470.76,472.63,474.5,476.37,478.24,480.11,481.97,483.84,485.71,487.58,489.45,491.31,493.18,495.05,496.92,498.79,500.66,502.52,504.39,506.26,508.13,510.0,511.86,513.73,515.6,517.47,519.34,521.2,523.07,524.94,526.81,528.68,530.55,532.41,534.28,536.15,538.02,539.89,541.75],"sy":[138.13,144.51,137.69,136.88,131.26,144.49,127.11,129.27,129.77,140.48,148.9,143.96,134.64,127.62,115.72,108.93,109.51,101.34,95.73,97.75,90.66,77.28,75.55,80.53,73.35,52.64,56.07,58.1,60.64,47.43,70.04,66.8,54.05,64.51,48.3,42.97,50.45,49.02,68.02,75.45,55.64,67.02,46.78,48.71,37.98,38.44,66.13,73.66,72.43,86.49,102.48,99.37,107.41,126.74,134.84,126.7,132.58,123.64,108.29,108.83,121.98,136.71,137.84,129.53,127.56,122.65,128.24,125.94,131.8,136.08,150.42,167.31,172.93,184.68,194.77,189.15,190.97,163.79,155.34,162.59,155.62,152.83,160.65,150.38,159.14,190.81,183.97,190.76,177.28,184.46,196.71,182.77,194.02,192.86,179.78,179.46,181.05,180.86,173.48,182.24,177.1,172.25,150.01,154.29,164.41,157.88,162.72,160.64,160.14,149.2,156.76,158.53,185.11,194.53,180.65,188.1,195.66,208.04,203.4,202.5,214.45,209.05,207.39,201.11,207.94,192.48,189.34,191.25,197.02,200.13,192.78,196.14,186.66,181.85,169.54,162.27,163.73,183.67,181.57,174.68,173.89,169.21,174.71,179.27,189.28,176.97,176.22,181.87,195.63,197.88,184.96,181.28,189.14,176.18,162.95,153.94,146.76,135.74,130.93,123.65,132.8,117.95,116.35,95.51,118.98,112.32,102.61,107.27,103.24,95.96,90.49,97.41,99.88,89.59,76.28,76.09,76.15,74.8,63.95,77.05,93.04,92.57,105.76,113.05,113.0,108.69,121.21,113.54,133.54,128.69,146.19,160.14,154.5,159.46,168.31,173.55,169.77,171.12,172.23,162.62,170.62,176.11,182.05,171.48,162.48,150.39,151.58,154.02,146.19,151.09,143.45,136.82,144.96,146.66,148.73,131.82,105.52,107.5,108.24,133.9,132.55,133.49,145.58,138.34,155.48,158.49,157.92,171.36,163.7,153.95,168.88,183.68,178.63,179.73,192.37,195.98,197.79,199.93,192.88,189.99,173.77,161.03,155.03,144.94,132.15,125.61,139.46,131.39,131.5,115.36,115.24,110.47]},{"panel":0,"label":"calm fund","color":"var(--chart-maroon, #b6262c)","kind":"line","x":[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.0,11.0,12.0,13.0,14.0,15.0,16.0,17.0,18.0,19.0,20.0,21.0,22.0,23.0,24.0,25.0,26.0,27.0,28.0,29.0,30.0,31.0,32.0,33.0,34.0,35.0,36.0,37.0,38.0,39.0,40.0,41.0,42.0,43.0,44.0,45.0,46.0,47.0,48.0,49.0,50.0,51.0,52.0,53.0,54.0,55.0,56.0,57.0,58.0,59.0,60.0,61.0,62.0,63.0,64.0,65.0,66.0,67.0,68.0,69.0,70.0,71.0,72.0,73.0,74.0,75.0,76.0,77.0,78.0,79.0,80.0,81.0,82.0,83.0,84.0,85.0,86.0,87.0,88.0,89.0,90.0,91.0,92.0,93.0,94.0,95.0,96.0,97.0,98.0,99.0,100.0,101.0,102.0,103.0,104.0,105.0,106.0,107.0,108.0,109.0,110.0,111.0,112.0,113.0,114.0,115.0,116.0,117.0,118.0,119.0,120.0,121.0,122.0,123.0,124.0,125.0,126.0,127.0,128.0,129.0,130.0,131.0,132.0,133.0,134.0,135.0,136.0,137.0,138.0,139.0,140.0,141.0,142.0,143.0,144.0,145.0,146.0,147.0,148.0,149.0,150.0,151.0,152.0,153.0,154.0,155.0,156.0,157.0,158.0,159.0,160.0,161.0,162.0,163.0,164.0,165.0,166.0,167.0,168.0,169.0,170.0,171.0,172.0,173.0,174.0,175.0,176.0,177.0,178.0,179.0,180.0,181.0,182.0,183.0,184.0,185.0,186.0,187.0,188.0,189.0,190.0,191.0,192.0,193.0,194.0,195.0,196.0,197.0,198.0,199.0,200.0,201.0,202.0,203.0,204.0,205.0,206.0,207.0,208.0,209.0,210.0,211.0,212.0,213.0,214.0,215.0,216.0,217.0,218.0,219.0,220.0,221.0,222.0,223.0,224.0,225.0,226.0,227.0,228.0,229.0,230.0,231.0,232.0,233.0,234.0,235.0,236.0,237.0,238.0,239.0,240.0,241.0,242.0,243.0,244.0,245.0,246.0,247.0,248.0,249.0,250.0,251.0],"y":[101.042,99.8036,100.045,99.7995,99.6118,99.5409,98.5838,98.5057,98.1199,99.763,99.9093,99.7706,99.6672,99.3738,98.8914,98.7355,99.005,98.9233,99.4256,99.3625,99.4094,100.203,100.507,100.292,100.237,100.539,101.535,101.435,101.349,101.886,101.476,101.366,101.843,102.17,102.252,102.626,101.231,101.776,101.33,100.532,100.704,101.088,100.901,100.401,100.449,100.458,101.19,101.599,101.732,102.326,102.258,101.827,102.156,102.486,102.413,102.054,102.205,100.983,101.363,101.644,100.858,100.924,100.479,100.89,99.913,99.4973,99.8806,100.486,99.4511,99.2417,99.4372,99.1733,99.9865,99.4341,99.643,99.1626,99.8853,99.9098,99.7615,98.9509,99.8067,100.213,100.62,101.221,101.431,101.146,100.783,100.42,101.134,100.441,100.181,100.057,100.204,100.523,99.9391,99.1213,99.154,99.7825,100.19,100.332,100.21,100.391,100.305,100.745,100.386,100.488,100.468,100.773,100.92,102.225,103.017,103.814,102.806,102.669,102.397,102.702,101.584,102.208,102.782,102.158,101.7,101.334,101.392,101.748,102.812,102.748,103.173,103.288,104.222,104.64,105.383,104.86,104.797,104.413,105.225,105.604,105.482,105.284,105.572,105.244,104.798,105.084,106.398,106.306,106.052,105.476,104.819,105.127,105.605,105.647,105.858,105.956,106.065,105.304,105.103,105.198,104.828,104.619,104.233,104.098,104.573,104.4,104.357,104.813,105.183,106.1,105.043,105.524,105.31,105.417,105.89,106.493,107.076,107.196,108.085,107.972,107.935,108.399,108.142,109.333,109.921,111.14,111.164,110.993,111.124,111.566,111.281,111.529,111.559,112.488,112.159,112.778,112.459,111.966,111.613,110.997,111.116,111.72,111.85,112.234,113.177,113.368,113.517,113.403,112.543,113.004,112.065,112.465,112.497,113.162,113.164,112.744,112.983,112.71,112.649,112.712,112.677,112.611,112.189,112.123,110.98,110.933,110.316,110.965,111.699,110.663,110.781,110.751,110.218,110.546,110.333,109.409,109.304,109.262,109.358,108.732,109.101,109.535,108.955,108.639,108.634,108.369,109.339,109.49,108.983,108.597,108.605,109.873,109.815,109.923,110.24,110.257],"sx":[72.85,74.72,76.58,78.45,80.32,82.19,84.06,85.92,87.79,89.66,91.53,93.4,95.27,97.13,99.0,100.87,102.74,104.61,106.47,108.34,110.21,112.08,113.95,115.82,117.68,119.55,121.42,123.29,125.16,127.02,128.89,130.76,132.63,134.5,136.36,138.23,140.1,141.97,143.84,145.71,147.57,149.44,151.31,153.18,155.05,156.91,158.78,160.65,162.52,164.39,166.26,168.12,169.99,171.86,173.73,175.6,177.46,179.33,181.2,183.07,184.94,186.81,188.67,190.54,192.41,194.28,196.15,198.01,199.88,201.75,203.62,205.49,207.35,209.22,211.09,212.96,214.83,216.7,218.56,220.43,222.3,224.17,226.04,227.9,229.77,231.64,233.51,235.38,237.25,239.11,240.98,242.85,244.72,246.59,248.45,250.32,252.19,254.06,255.93,257.8,259.66,261.53,263.4,265.27,267.14,269.0,270.87,272.74,274.61,276.48,278.34,280.21,282.08,283.95,285.82,287.69,289.55,291.42,293.29,295.16,297.03,298.89,300.76,302.63,304.5,306.37,308.24,310.1,311.97,313.84,315.71,317.58,319.44,321.31,323.18,325.05,326.92,328.78,330.65,332.52,334.39,336.26,338.13,339.99,341.86,343.73,345.6,347.47,349.33,351.2,353.07,354.94,356.81,358.68,360.54,362.41,364.28,366.15,368.02,369.88,371.75,373.62,375.49,377.36,379.23,381.09,382.96,384.83,386.7,388.57,390.43,392.3,394.17,396.04,397.91,399.77,401.64,403.51,405.38,407.25,409.12,410.98,412.85,414.72,416.59,418.46,420.32,422.19,424.06,425.93,427.8,429.67,431.53,433.4,435.27,437.14,439.01,440.87,442.74,444.61,446.48,448.35,450.22,452.08,453.95,455.82,457.69,459.56,461.42,463.29,465.16,467.03,468.9,470.76,472.63,474.5,476.37,478.24,480.11,481.97,483.84,485.71,487.58,489.45,491.31,493.18,495.05,496.92,498.79,500.66,502.52,504.39,506.26,508.13,510.0,511.86,513.73,515.6,517.47,519.34,521.2,523.07,524.94,526.81,528.68,530.55,532.41,534.28,536.15,538.02,539.89,541.75],"sy":[153.36,161.56,159.96,161.59,162.83,163.3,169.63,170.15,172.71,161.83,160.86,161.78,162.46,164.4,167.6,168.63,166.85,167.39,164.06,164.48,164.17,158.92,156.9,158.32,158.69,156.69,150.1,150.76,151.33,147.77,150.48,151.22,148.06,145.89,145.35,142.87,152.11,148.5,151.45,156.74,155.6,153.06,154.29,157.6,157.28,157.22,152.38,149.67,148.79,144.86,145.31,148.16,145.98,143.8,144.28,146.66,145.66,153.75,151.24,149.37,154.58,154.14,157.08,154.37,160.83,163.59,161.05,157.04,163.89,165.28,163.98,165.73,160.35,164.0,162.62,165.8,161.02,160.86,161.84,167.2,161.54,158.85,156.15,152.18,150.79,152.67,155.08,157.48,152.75,157.34,159.06,159.88,158.91,156.79,160.66,166.08,165.86,161.7,159.0,158.06,158.86,157.67,158.24,155.32,157.7,157.03,157.16,155.14,154.17,145.53,140.29,135.01,141.68,142.59,144.39,142.37,149.77,145.64,141.84,145.97,149.0,151.42,151.05,148.69,141.64,142.07,139.25,138.49,132.31,129.54,124.62,128.08,128.5,131.04,125.66,123.16,123.96,125.28,123.37,125.54,128.49,126.6,117.9,118.51,120.19,124.0,128.36,126.31,123.15,122.87,121.48,120.83,120.1,125.14,126.47,125.85,128.29,129.68,132.24,133.13,129.98,131.13,131.41,128.39,125.94,119.87,126.87,123.69,125.1,124.4,121.27,117.27,113.41,112.62,106.73,107.48,107.72,104.65,106.35,98.47,94.58,86.51,86.35,87.48,86.61,83.69,85.57,83.93,83.73,77.58,79.76,75.66,77.77,81.04,83.38,87.46,86.67,82.66,81.81,79.26,73.02,71.76,70.77,71.53,77.22,74.16,80.38,77.73,77.52,73.12,73.11,75.89,74.31,76.11,76.52,76.1,76.33,76.76,79.56,80.0,87.57,87.88,91.96,87.67,82.81,89.66,88.88,89.08,92.61,90.44,91.85,97.96,98.66,98.94,98.3,102.45,100.01,97.13,100.97,103.07,103.1,104.85,98.43,97.43,100.79,103.34,103.29,94.89,95.28,94.57,92.46,92.35]}]} 2026-10-31T01:55:38.381562 image/svg+xml Matplotlib v3.11.2, https://matplotlib.org/ 0 50 100 150 200 250 Trading day of the year (1–252) 95 100 105 110 115 V a l u e   o f   1 0 0 ( ) i n v e s t e d 1. Two made-up funds with the same average daily return (0.04%) wild fund calm fund −4 −2 0 2 4 Daily return (%) 0 10 20 30 40 50 Number of days (of 252) 2. The same two funds: very different spread of daily returns wild: sd 1.5% calm: sd 0.5%
Figure 1. Two funds with the same mean and different standard deviations

Table 4. The calm fund against the wild fund after one year
ItemCalm fundWild fund
Average daily return0.04%0.04%
Daily standard deviation0.50%1.50%
$100 after one year$110.26\good{\usd 110.26}$107.52\good{\usd 107.52}

Same average, but the wild fund ended lower (Table 4). One simulated year could be luck, but this gap is not: a fund that swings more grows slower on average, for a reason built into the arithmetic. Losses hurt more than equal gains help: lose 10% and then gain 10%, and you’re at 99%, not 100%. The more a fund swings, the more this “volatility drag” eats into growth. A rough rule, from the returns post: the yearly growth rate is about the average return minus half the variance.

From daily to yearly: why 252\sqrt{252}

There are about 252 trading days in a year. To turn daily numbers into yearly ones, with μ\key{\mu} for the mean and σ\risk{\sigma} for the standard deviation:

μannual≈252×μdaily\key{\mu_{\text{annual}}} \approx 252 \times \key{\mu_{\text{daily}}} σannual≈252×σdaily\risk{\sigma_{\text{annual}}} \approx \sqrt{252} \times \risk{\sigma_{\text{daily}}}

The mean grows with the number of days, but the standard deviation grows with the square root. Why?

If days are independent, their variances add up. Over 252 days:

Var(year)=252×Var(day)\risk{\text{Var}}(\text{year}) = 252 \times \risk{\text{Var}}(\text{day}) SD(year)=252×Var(day)\risk{\text{SD}}(\text{year}) = \sqrt{252 \times \risk{\text{Var}}(\text{day})} SD(year)=252×SD(day)\risk{\text{SD}}(\text{year}) = \sqrt{252} \times \risk{\text{SD}}(\text{day})

Good days and bad days partly cancel out, so risk grows more slowly than time. I checked it by simulating 20,000 years of independent days with a 1% daily standard deviation. The standard deviation of the yearly totals came out at 15.86%\risk{15.86\%}. The formula says 252×1%=15.87%\sqrt{252} \times 1\% = 15.87\%.

For our funds: the calm one is 0.5%×252=7.94%0.5\% \times \sqrt{252} = 7.94\% a year, the wild one 23.81%\risk{23.81\%}.

The same 252\sqrt{252} shows up in the Sharpe ratio, which has its own post in this series.

The 68–95–99.7 rule, and why markets break it

If returns follow a normal distribution (the bell curve), the standard deviation tells you a lot (Table 5):

Table 5. Share of days within 1, 2 and 3 standard deviations, normal curve
WithinShare of days (normal)
1 standard deviation of the mean68.3%
2 standard deviations95.4%
3 standard deviations99.7%

Real market returns are not quite normal. They have fat tails: extreme days happen far more often than the bell curve says. Take a fat-tailed distribution (Student’s t with 3 degrees of freedom, a standard bell-like curve with heavier ends) scaled to the same standard deviation, and ask how often a day lands more than 4 standard deviations from the mean (Table 6):

Table 6. Days beyond 4 standard deviations, normal against fat-tailed
ItemNormalFat-tailed
Days beyond 4 standard deviations0.0063% (1 day in about 16,000)0.62%\risk{0.62\%} (1 day in about 160)

About 100 times more extreme days (0.62/0.0063≈970.62 / 0.0063 \approx 97). Simulating a million days of each gives the same picture. A risk model that assumes the bell curve will badly underestimate how often a crash day comes. The standard deviation is a good summary of everyday risk, and a poor guide to the worst days.

The code

The 2020 to 2025 numbers and the worked week. It reads the blog’s price file from the examples repo, so it runs as pasted (pip install numpy pandas). prices holds the five tickers’ daily closes, one column each; returns the daily returns; spy SPY’s column of them.

import numpy as np
import pandas as pd

URL = "https://raw.githubusercontent.com/ankurtrapasiya/examples/main/data/prices.csv"
prices = pd.read_csv(URL, index_col="date", parse_dates=True)   # adjusted closes, 5 tickers
returns = prices / prices.shift(1) - 1           # r_t = p_t / p_(t-1) - 1, one column per ticker

spy = returns["SPY"].dropna()                    # dropna: the first day has no day before it
mean = spy.mean()                                # 0.00065  (0.065% a day)
sd = spy.std()                                   # 0.0132   (1.32%); pandas divides by n - 1
sd_pop = spy.std(ddof=0)                         # divides by n, numpy's default
print(f"mean {mean:.5f}, sd {sd:.4f}, population sd {sd_pop:.4f}")

annual_mean = mean * 252                         # 16.4%
annual_sd = sd * np.sqrt(252)                    # 20.9%
growth = 100 * (1 + spy).prod()                  # $100 -> $228 over 2020-2025
print(f"annual mean {annual_mean:.1%}, annual sd {annual_sd:.1%}, $100 became ${growth:.0f}")

week = np.array([-0.8, 0.4, -0.3, 0.5, 0.7])     # the worked example, in %
print(week.mean().round(2), np.std(week, ddof=1).round(2), np.std(week).round(2))   # 0.1  0.63  0.56

It prints SPY’s daily mean and standard deviation (0.00065 and 0.0132; with over a thousand days, dividing by nn or n−1n - 1 makes no visible difference), then the yearly figures (16.4%, 20.9%) and the $228, then the worked week: mean 0.1, sample standard deviation 0.63, population 0.56, where five days make the difference large.

Summary

Table 7 collects the formulas.

Table 7. Formulas worth remembering
IdeaFormulaRemember it as
Daily returnrt=pt/pt−1−1\good{r_t} = p_t / p_{t-1} - 1Percent change (SPY: −0.8% on 2020’s second day)
Meanrˉ=∑rt/n\key{\bar{r}} = \sum \good{r_t} / nWhere the middle is
Sample standard deviations=∑(rt−rˉ)2/(n−1)\risk{s} = \sqrt{\sum (\good{r_t} - \key{\bar{r}})^2 / (n-1)}Typical distance from the middle
Annualise the mean×252\times 252Grows with time
Annualise the standard deviation×252\times \sqrt{252}Grows with the square root of time
Volatility draggrowth ≈\approx mean − variance / 2Swings cost you, even with the same average

References

Tagged statistics, finance, returns, risk← Home