The Claude Quant PlaybookDownload ebookDownload ebook

Confidence interval for a mean

beginnerStatistics4 of 10

A range around the sample mean that, built this way on repeated samples, covers the true mean the stated share of the time. Wider means less certain.

Build a trading system with Claude.Download ebook

01The formula

the sample mean
the sample standard deviation
the number of observations
the normal quantile for your confidence level: 1.96 for 95%
one minus the confidence level

02See it move

03Where it is used

04Why traders use it

A backtest average without an interval invites overconfidence. If the interval includes zero, the data have not shown an edge.

05Worked example

A sample mean of 0.08% per day with volatility 1.0% over 250 days gives a 95% interval from −0.044% to 0.204%, a half-width of 0.124% using z = 1.960. It still includes zero.

06How it is built

  1. The standard error of is .
  2. For large , is close to a standard normal.
  3. So with probability it lies between and .
  4. Rearrange for : .

07The common mistake

Saying there is a 95% chance the true mean is in this particular interval. The 95% describes the method over many samples; with small samples you should also use the t quantile, not z.

08In Python and LaTeX

import numpy as np
from scipy.stats import norm
xbar, s, n, c = 0.0008, 0.01, 250, 0.95
h = norm.ppf(1 - (1 - c)/2) * s / np.sqrt(n)
print(round(xbar - h, 6), round(xbar + h, 6))
\bar{x} \pm z_{1 - \alpha/2}\,\frac{s}{\sqrt{n}}

09Where it fits

Rather not code the maths yourself? Describe your trading idea and let AI build the bot.

Build a bot with AgenKit

The worked example and the model run the same code, so every number matches. Models simplify markets on purpose. This is education, not financial advice.