A beginner-friendly statistics guide: what a t-test does, the main types, the formula, assumptions, a step-by-step example, how to read p-values and the tools used to run t-tests.
Quick answer: A t-test is a statistical test that checks whether the difference between the means (averages) of one or two groups is statistically significant, or likely due to random chance. There are three main types: a one-sample t-test compares a sample mean to a known value, an independent (two-sample) t-test compares two separate groups, and a paired t-test compares the same group at two times or under two conditions. If the resulting p-value is below a chosen threshold, often 0.05, the difference is considered statistically significant.
Did a new teaching method really improve exam scores? Does a new website design increase time on page? Is one batch of products heavier than another? Questions like these involve comparing averages, and the t-test is one of the most common tools for answering them.
This guide explains what a t-test is in simple terms, when to use each type, the basic formula and assumptions, a worked example and how to interpret the results. It is written for students, researchers and anyone working with data, with no advanced maths required.
In this article
- What is a t-test in simple terms?
- What are the main types of t-tests?
- One-tailed vs two-tailed t-tests
- What is the t-test formula?
- T-test example step by step
- How do you interpret t-test results?
- What are the assumptions of a t-test?
- How do you run a t-test?
- Frequently Asked Questions
- Final Thoughts
What is a t-test in simple terms?
A t-test compares averages while taking into account how spread out the data is and how many observations you have. It produces a t-value (how large the difference is relative to the variation in the data) and a p-value (how likely you would see a difference this large if there were truly no difference).
The test was developed by William Sealy Gosset, a chemist at the Guinness brewery in Dublin, who published it in 1908 under the pen name “Student”. That is why it is often called Student’s t-test. He needed a way to draw reliable conclusions from small samples of barley and beer.
What are the main types of t-tests?
| Type | What it compares | Example |
|---|---|---|
| One-sample t-test | A sample mean against a known or target value | Is the average weight of cereal boxes different from the labelled 500 g? |
| Independent (two-sample) t-test | The means of two separate, unrelated groups | Do customers using Website A spend more than those using Website B? |
| Paired (dependent) t-test | Two measurements from the same subjects | Did employees’ test scores improve after a training course? |
There is also Welch’s t-test, a version of the independent t-test that does not assume the two groups have equal variances. Many statisticians recommend it as the default for comparing two groups.
One-tailed vs two-tailed t-tests
A two-tailed test checks for a difference in either direction (higher or lower). A one-tailed test checks for a difference in one specific direction only, for example whether a new method is better, not just different. Two-tailed tests are more common and more conservative; one-tailed tests should only be used when the direction was predicted before collecting data.
What is the t-test formula?
For a one-sample t-test, the formula is:
t = (x̄ − μ) ÷ (s ÷ √n)
- x̄: the sample mean
- μ: the value you are comparing against (population or target mean)
- s: the sample standard deviation
- n: the sample size
The bottom part, s ÷ √n, is called the standard error. Independent and paired t-tests use similar logic with formulas adjusted for two groups or for the differences between pairs. The degrees of freedom (often n − 1 for a one-sample test) determine which t-distribution is used to find the p-value.
T-test example step by step
A cereal company claims each box contains 500 g. A quality inspector weighs a random sample of 16 boxes and finds a mean of 495 g with a standard deviation of 8 g. Is the average weight significantly different from 500 g?
- Hypotheses: null hypothesis H₀: μ = 500 g; alternative hypothesis H₁: μ ≠ 500 g (two-tailed).
- Significance level: α = 0.05.
- Standard error: 8 ÷ √16 = 8 ÷ 4 = 2.
- t-value: (495 − 500) ÷ 2 = −2.5.
- Degrees of freedom: 16 − 1 = 15.
- Critical value: for a two-tailed test at 0.05 with 15 degrees of freedom, about ±2.131.
- Decision: |−2.5| is greater than 2.131, so we reject the null hypothesis. The p-value is about 0.025.
Conclusion: the boxes weigh significantly less than 500 g on average, so the company should check its filling machines.
How do you interpret t-test results?
| Result | What it means |
|---|---|
| p-value < 0.05 | The difference is statistically significant at the 5% level; reject the null hypothesis |
| p-value ≥ 0.05 | Not enough evidence of a difference; fail to reject the null hypothesis |
| Large absolute t-value | The difference is large compared with the variation in the data |
| Confidence interval excluding zero (for differences) | Consistent with a significant difference |
| Effect size (e.g. Cohen’s d) | Shows how big and practically meaningful the difference is |
Statistical significance is not the same as practical importance. With very large samples, tiny differences can be “significant” but not useful. Always report the size of the difference and an effect size alongside the p-value.
What are the assumptions of a t-test?
- Continuous data: measured on an interval or ratio scale, such as weight, time or scores
- Random sampling: observations should represent the population
- Independence: observations within groups are independent (except pairs in a paired test)
- Approximately normal distribution: especially important for small samples
- Similar variances: for the classic Student’s independent t-test; use Welch’s test if variances differ
If assumptions are badly violated, non-parametric alternatives such as the Mann–Whitney U test or Wilcoxon signed-rank test may be more appropriate. Comparing three or more groups calls for ANOVA instead of multiple t-tests.
A school compared maths scores of 30 students before and after an online tutoring programme using a paired t-test. The average score rose by 6 points with p = 0.01, suggesting the improvement was unlikely to be due to chance.
How do you run a t-test?
- Excel and Google Sheets: the T.TEST function returns a p-value
- SPSS, Stata and JMP: menu-driven statistical software
- R: the t.test() function
- Python: scipy.stats functions such as ttest_ind and ttest_rel
- Online calculators: quick checks for small datasets
Explore more options in our guide to data analysis tools, and see how statistics fits into wider data and information analysis. The NIST Engineering Statistics Handbook provides a detailed technical reference.
Open a spreadsheet, enter two small sets of numbers (for example, your weekly step counts for two months) and use =T.TEST(range1, range2, 2, 3) to run a two-tailed Welch’s t-test.
Frequently Asked Questions
What does a t-test tell you?
Whether the difference between means is likely to be real or could easily be explained by random variation.
When should I use a t-test?
When comparing the means of one or two groups with continuous data, especially with small to moderate sample sizes.
What is a good p-value for a t-test?
A p-value below 0.05 is commonly treated as statistically significant, though the threshold should be chosen before analysis.
What is the difference between a t-test and a z-test?
A z-test assumes the population standard deviation is known and is used for large samples; a t-test uses the sample standard deviation and suits smaller samples.
Can I use a t-test for more than two groups?
No. Use ANOVA to compare three or more groups, then follow-up tests if needed.
What is a paired t-test used for?
Comparing two related measurements from the same subjects, such as before and after a treatment or training.
Final Thoughts
- A t-test compares means to see if differences are statistically significant.
- Choose one-sample, independent (or Welch’s) or paired depending on your data.
- The t-value and p-value guide your decision about the null hypothesis.
- Check assumptions and report effect sizes, not just p-values.
- Excel, R, Python and statistical software can all run t-tests.




