z-test for a mean
Measure how many standard errors the sample mean is from the value the null hypothesis claims. If that distance is beyond the critical value, reject the null.
01The formula
- the test statistic
- the sample mean
- the mean under the null hypothesis, here 0 (no edge)
- the known standard deviation of one observation
- the number of observations
- the null hypothesis you are testing
- the significance level: the false alarm rate you accept
- the critical value, 1.96 for α = 5%
02See it move
03Where it is used
- Quant researcherTests whether a signal's average return differs from zero over a long sample.
- Risk managerChecks whether average daily P&L has drifted away from its expected level.
- Execution traderTests whether a new algorithm's average slippage differs from the old one.
04Why traders use it
It is the simplest formal answer to 'is this real or luck?'. With large samples and a well-estimated volatility, it is all you need.
05Worked example
An average daily return of 0.12% over 252 days with volatility 1.0% gives z = 1.905. The critical value at α = 5% is 1.960, and the p-value is 5.68%: close, but not enough to reject 'no edge'.
06How it is built
- Under the sample mean has mean and standard error .
- So is standard normal if is true.
- Pick . Only of no-edge samples give .
- If yours does, reject ; otherwise the data are consistent with it.
07The common mistake
Reading 'not significant' as 'no edge'. Failing to reject only means the sample is too small or noisy to tell; the edge may still be there.
08In Python and LaTeX
import numpy as np from scipy.stats import norm xbar, sigma, n = 0.0012, 0.01, 252 z = xbar / (sigma/np.sqrt(n)) print(round(z, 3), round(norm.ppf(0.975), 3), round(2*norm.sf(abs(z)), 4))
z = \frac{\bar{x} - \mu_0}{\sigma / \sqrt{n}}, \qquad \text{reject } H_0 \text{ if } |z| > z_{1 - \alpha/2}09Where 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.