Sample mean
Add the observations and divide by how many there are. It is the best simple guess at the true mean, but it moves from sample to sample.
01The formula
- the sample mean: the average of the data you have
- the i-th observation, such as one day's return
- how many observations
- the true mean you are trying to learn
02See it move
03Where it is used
- Quant researcherEstimates a strategy's average daily return from its backtest.
- Portfolio managerCompares managers or funds by their average monthly returns.
- Execution traderMeasures average slippage per order over a batch of trades.
04Why traders use it
Almost every number in a backtest report is a sample mean. It is unbiased, but with daily returns the noise in it is often bigger than the edge you are measuring.
05Worked example
A sample of 60 days from a market with true mean 0.05% and volatility 1.0% has a sample mean of −0.013%. Its error x̄ − μ is −0.063%; the typical error at this sample size is 0.129%.
06How it is built
- Each observation has mean , so by linearity : no bias.
- With independent observations of variance , .
- So its typical error is , which shrinks as you add data.
07The common mistake
Taking a positive average return as proof of an edge. With 1% daily volatility and 60 days the typical error of the mean is far larger than a realistic daily edge.
08In Python and LaTeX
import numpy as np
rng = np.random.default_rng(7)
mu, sigma, n = 0.0005, 0.01, 60
x = rng.normal(mu, sigma, n)
xbar = x.mean() # your sample will differ from the page's
print('typical error:', round(sigma/np.sqrt(n), 5))\bar{x} = \frac{1}{n}\sum_{i=1}^{n} x_i, \qquad E[\bar{x}] = \mu09Where it fits
Rather not code the maths yourself? Describe your trading idea and let AI build the bot.
Build a bot with AgenKitThe worked example and the model run the same code, so every number matches. Models simplify markets on purpose. This is education, not financial advice.