What is a t-test?
A t-test compares means using the t distribution, for when the standard deviation comes from your sample. A one-sample test checks a mean against a set value, a two-sample test compares two separate groups, and a paired test compares two measurements on the same people or things (before and after), by testing their differences.
For two samples, Welch’s test doesn’t assume the two groups have equal variances, and its degrees of freedom need not be a whole number. The pooled test assumes equal variances and uses n₁ + n₂ − 2 degrees of freedom.
Source NIST/SEMATECH e-Handbook · 1.3.5.3 Two-Sample t-Test for Equal Means ↗OpenStax Introductory Statistics 2e · 10.1 Two Population Means with Unknown Standard Deviations ↗OpenStax Introductory Statistics 2e · 10.4 Matched or Paired Samples ↗
How to calculate a t-test
Here it is with your numbers:
- Standard error: √(s₁²/n₁ + s₂²/n₂) = 0.381875
- t statistic: −1.2 ÷ 0.381875 = −3.1424
- Degrees of freedom (Welch): 18.8466
- Two-tailed p-value: 2 × the area beyond 3.1424, which is 0.0054
It means that if the null hypothesis were true, a t this far out in either direction would turn up with a probability of 0.0054.
Source NIST/SEMATECH e-Handbook · 7.2.2 Are the data consistent with the assumed process mean? ↗
T-test examples
Worked examples from NIST’s handbook and OpenStax’s statistics textbook. Tap one to load it.
| Example | t | df | p-value |
|---|---|---|---|
| Wafer particle counts vs 50 (one sample) | 1.7817 | 9 | 0.1085 |
| Girls vs boys, hours of sport (Welch) | −3.1424 | 18.8466 | 0.0054 |
| US vs Japanese cars, mpg (pooled) | −12.6206 | 326 | 5.2732 × 10⁻³⁰ |
| Pain before and after hypnotism (paired, left) | −3.0423 | 7 | 0.0094 |
FAQs
How to do the t-test step by step?
State the null hypothesis (for example, the mean is 50). Work out t = (x̄ − μ₀) ÷ (s ÷ √n) with n − 1 degrees of freedom, find the p-value (or the critical value) from the t distribution, and reject the null hypothesis if the p-value is below your significance level.
Source NIST/SEMATECH e-Handbook · 7.2.2 Are the data consistent with the assumed process mean? ↗
What is the t-test formula?
For one sample, t = (x̄ − μ₀) ÷ (s ÷ √n). For two samples, t = (x̄₁ − x̄₂) ÷ √(s₁²/n₁ + s₂²/n₂), or with the pooled standard deviation when the variances are assumed equal.
Source NIST/SEMATECH e-Handbook · 1.3.5.3 Two-Sample t-Test for Equal Means ↗
How do I calculate t *?
t* is the critical value of the t distribution for your degrees of freedom and significance level. For a two-sided test at α = 0.05 with 9 degrees of freedom, it is 2.262: reject the null hypothesis if |t| is bigger than that.
Source NIST/SEMATECH e-Handbook · 7.2.2 Are the data consistent with the assumed process mean? ↗
Sources
- NIST/SEMATECH e-Handbook: 7.2.2 Are the data consistent with the assumed process mean?
- NIST/SEMATECH e-Handbook: 1.3.5.3 Two-Sample t-Test for Equal Means
- OpenStax Introductory Statistics 2e: 10.1 Two Population Means with Unknown Standard Deviations
- OpenStax Introductory Statistics 2e: 10.4 Matched or Paired Samples