One-Sample T-Test Calculator
Paste one column of numbers and the value you are testing against…
Paste one column of numbers and the value you are testing against, such as a label’s 500 g, to see whether the true mean could be that value.
Read 12 values; left out the header row (“Box weight (g)”).
More optionsTwo-sided, 95% confidence
The significance level is 1 − the confidence level (0.05 at 95%).
ExampleP-value
0.0335
The mean is 498.475 (95% CI 497.1 to 499.9), 1.525 below 500. Significant at the 5% level (p < 0.05).
Paste your own numbers to test them.
Every value is a dot; the bar under the diamond is the mean’s confidence interval. Drag the target line to test another value.
The distribution the statistic follows if there were no difference; the shaded area beyond it is the p-value.
- t, df
- −2.4283, 11
- Cohen’s d (Hedges g)
- −0.701 (−0.652)
- Mean, 95% CI
- 498.475 [497.1 to 499.9]
How this works: 9 sources,
How this works
Method
A one-sample t-test checks a sample’s mean against a fixed value: a label’s 500 g, a target response time, last year’s average, a published norm. In the example, twelve cereal boxes weighed 498.5 g on average, 1.5 g under the label. The test asks whether a shortfall that size could easily come from twelve boxes of a process that really averages 500 g. Full method
Sources
- NIST/SEMATECH e-Handbook of Statistical Methods, 1.3.5.2 Confidence Limits for the Mean
- Wikipedia, Student’s t-test
- NIST/SEMATECH e-Handbook of Statistical Methods
- Abramowitz and Stegun, Handbook of Mathematical Functions, chapters 6, 7 and 26 (1964)
- SciPy 1.18 scipy.stats (reference values for the tests)
- statsmodels 0.15 (reference values for the A/B test and regression intervals)
- Welch, The generalization of Student’s problem when several different population variances are involved (Biometrika) (1947)
- Fleiss, Levin and Paik, Statistical Methods for Rates and Proportions, 3rd edition (sample size for two proportions) (2003)
- Hyndman and Fan, Sample quantiles in statistical packages (The American Statistician) (1996)
How it’s tested
2 worked examples for this page are checked by automated tests before every release: given the inputs, the tool must show the expected answer.
Privacy
On your device. Nothing you enter or open leaves this browser. About privacy labels
Changes
- First published: live curves with draggable cut-offs, and tests on pasted data (t-tests, ANOVA, chi-square, Fisher’s exact, correlation, regression, A/B), checked against SciPy.
How the one-sample t-test works
A one-sample t-test checks a sample’s mean against a fixed value: a label’s 500 g, a target response time, last year’s average, a published norm. In the example, twelve cereal boxes weighed 498.5 g on average, 1.5 g under the label. The test asks whether a shortfall that size could easily come from twelve boxes of a process that really averages 500 g.
It divides the distance from the target by the standard error of the mean: t = (x̄ − μ₀) ÷ (s ÷ √n), with n − 1 degrees of freedom. With these boxes the standard error is about 0.6 g, so 1.5 g is about 2.4 standard errors away, and p is about 0.03. Drag the target line on the plot to see how the answer changes for other values: everything inside the confidence interval would not be rejected.
That link between the test and the interval is worth using. The 95% confidence interval for the mean contains exactly the target values a two-sided test at 5% would not reject, and it says more: here the true average is likely between 497.1 and 499.9 g, which a buyer may or may not care about.
t = (x̄ − μ₀) ÷ (s ÷ √n), df = n − 1 · CI = x̄ ± t* × s ÷ √n
- The confidence limits for a mean are Ȳ ± t(1 − α/2, N − 1) × s/√N, using the t distribution because the standard deviation is estimated from the sample. Source: NIST/SEMATECH e-Handbook of Statistical Methods, 1.3.5.2 Confidence Limits for the Mean.
- Student’s t-test was published by William Sealy Gosset in 1908 under the pen name “Student” while he worked on small samples at the Guinness brewery. Source: Wikipedia, Student’s t-test.
How wide the 95% interval is, in standard deviations
The critical t value and the 95% margin of error of a mean as a multiple of the sample standard deviation, by sample size (t* ÷ √n).
| Sample size | df | t* | Margin (× SD) |
|---|---|---|---|
| 2 | 1 | 12.706 | ±8.985 |
| 3 | 2 | 4.303 | ±2.484 |
| 4 | 3 | 3.182 | ±1.591 |
| 5 | 4 | 2.776 | ±1.242 |
| 6 | 5 | 2.571 | ±1.049 |
| 8 | 7 | 2.365 | ±0.836 |
| 10 | 9 | 2.262 | ±0.715 |
| 12 | 11 | 2.201 | ±0.635 |
| 15 | 14 | 2.145 | ±0.554 |
| 20 | 19 | 2.093 | ±0.468 |
Show all 14 rowsShow fewer
| 30 | 29 | 2.045 | ±0.373 |
| 50 | 49 | 2.01 | ±0.284 |
| 100 | 99 | 1.984 | ±0.198 |
| 1,000 | 999 | 1.962 | ±0.062 |
Common questions
What value should I test against?
The one you care about before seeing the data: a specification, a label, a target, a known population mean. Testing against a value chosen after looking at the data makes the p-value meaningless.
Can I run it with only two values?
Yes, the test works from n = 2, but with one degree of freedom the critical t is 12.7, so only a huge difference reaches significance. The table above shows how quickly the interval narrows as n grows.
What if every value is the same?
Then there is no spread and the standard error is zero, so the t statistic is undefined; the page says so instead of giving a fake p-value. The mean is simply that value.