The one-sample t test
H₀: μ = 5 · H₁: μ ≠ 5
t = 1.9795 · df = 11 · p = 0.0733
p = 0.0733 > α = 0.05: H₀ is not rejected. The data do not rule out a true mean of 5, but that is not proof that it is 5.
How to read the picture
The curve is the null world: how t would vary from sample to sample if the true mean were μ₀.
The vertical line is your t: how many standard errors your mean lies from μ₀.
The p-value area is the chance of a t at least as extreme as yours if μ₀ were true.
The rejection region at α is where t must land for the test to reject H₀. It lands there exactly when p ≤ α.
Your data
Tails
Significance level
Twelve invoices took 5.8 days on average to process, with a standard deviation of 1.4 days, against a promise of 5 days. Is that gap real, or the kind of difference that luck alone produces? Move the numbers and watch where t lands on the curve of the null world, and how much of the curve lies beyond it.
The worked steps
Standard error of the mean
SE = s / √n = 1.4 / √12 = 0.4041Distance from μ₀
x̄ − μ₀ = 5.8 − 5 = 0.8The t statistic
t = (x̄ − μ₀) / SE = 0.8 / 0.4041 = 1.9795Degrees of freedom
df = n − 1 = 12 − 1 = 11The p-value
p = 2 × P(T ≥ |t|) = 2 × 0.03667 = 0.0733Critical value at α
α = 0.05: t* = ±2.201Confidence interval for μ
95 %: x̄ ± t* × SE = 5.8 ± 2.201 × 0.4041 = [4.9105, 6.6895]Effect size (Cohen's d)
d = (x̄ − μ₀) / s = 0.8 / 1.4 = 0.5714
The same in code
- Python (scipy.stats), from the summary statistics
from scipy import stats t = (5.8 - 5) / (1.4 / 12 ** 0.5) p = 2 * stats.t.sf(abs(t), df=11)- Python (scipy.stats), from the data in x
from scipy import stats stats.ttest_1samp(x, popmean=5, alternative='two-sided')- Python (statsmodels), from the data in x
from statsmodels.stats.weightstats import DescrStatsW DescrStatsW(x).ttest_mean(5, alternative='two-sided')- Excel
B1: =(5.8-5)/(1.4/SQRT(12)) B2: =T.DIST.2T(ABS(B1), 11)
Formulas
t counts how many standard errors the sample mean lies from μ₀. Under H₀ it follows Student's t with n − 1 degrees of freedom, which has heavier tails than the normal when n is small.
Try this
More data, same gap
Keep the mean at 5.8 and the standard deviation at 1.4, and drag n from 4 up to 40.
Look for: The gap of 0.8 days does not change, but the standard error shrinks, so t grows and the p-value falls below 0.05. Significance depends on n as much as on the size of the effect.
One tail or two
Switch between two-tailed and right-tailed while the data stay as they are.
Look for: The right-tailed p-value is half the two-tailed one here, and it crosses 0.05 when the two-tailed one does not. That is why the tail is chosen before the data are seen.
t against the normal
Show the normal curve and drag n from 3 to 30.
Look for: With few observations the t curve has heavier tails than the normal, so the same t gives a larger p-value. By about 30 the two curves are hard to tell apart.