The t-test asks whether a difference between means is larger than chance alone would easily produce when the population standard deviation is unknown — the usual situation with real data. William Sealy Gosset published it in 1908 under the pen name "Student", which is why the reference distribution is called Student’s t distribution.
This calculator runs the three common versions:
- One sample: compare a sample mean with a reference value (a target, a label claim, zero effect).
- Two independent samples: compare two groups, either with Welch’s test (no assumption of equal variances, the safer default) or the classic pooled Student test.
- Paired: compare two measurements on the same subjects (before/after, left/right); the test works on the differences.
Enter summary statistics (mean, standard deviation, size) or paste raw data. You get the t statistic, the degrees of freedom (Welch–Satterthwaite for unequal variances), an exact p-value for a two-tailed or one-tailed alternative, the critical value, the confidence interval of the mean or difference, Cohen’s and the decision at your significance level.
How to use this calculator
- Pick the test: one sample, two samples or paired.
- Choose summary statistics or raw data. For a paired test with raw data, enter the two lists in the same subject order.
- For two samples, choose Welch (unequal variances) unless you have a good reason to assume equal variances.
- Set the hypothesised value: for one sample, the difference (usually 0) otherwise.
- Choose the alternative hypothesis (≠, < or >) and the significance level α (0.05 by default).
- Read t, the p-value and the decision; the steps show the standard error and degrees of freedom.
The formula
One sample (and paired, applied to the differences ):
Two samples, Welch:
Two samples, pooled (equal variances):
The p-value comes from the Student t distribution, , doubled for a two-tailed test. The confidence interval is $\text{estimate} \pm t^* \times SE$ with $t^*$ the quantile (one-sided bound with for a one-tailed test). Cohen’s divides the difference by (or ).
Worked example
Welch two-sample test (OpenStax Introductory Statistics, Example 10.1). Daily sports time: 9 girls, mean 2 h, s = 0.866; 16 boys, mean 3.2 h, s = 1.
- , with
- Two-tailed p-value 0.0054 < 0.05: reject . The 95 % interval for the difference runs from -2 to -0.4 hours.
Paired test (raw-data default: extra hours of sleep for 10 patients under two drugs). The differences have mean −1.58 and , so and with 9 df. The two-tailed p-value is 0.0028; with $t^* = 2.2622$ the 95 % interval for the mean difference is -2.46 to -0.7 hours.
Which t-test should I use?
| Situation | Test | Degrees of freedom |
|---|---|---|
| One group vs a known value | One-sample | |
| Two unrelated groups | Welch two-sample | Welch–Satterthwaite (decimal) |
| Two unrelated groups, variances known to be similar | Pooled (Student) | |
| Same subjects measured twice, or matched pairs | Paired | pairs − 1 |
Running an unpaired test on paired data throws away the pairing and usually loses a lot of power — in the sleep example the paired p-value is about 0.003, while a Welch test on the same numbers gives about 0.08. Many statisticians recommend Welch’s version by default, because it performs almost as well as the pooled test when variances are equal and much better when they are not.
Assumptions and interpretation
The t-test assumes independent observations and roughly normal data — or, thanks to the central limit theorem, samples large enough (about 30 per group is a common rule of thumb) for the mean to be close to normal. Strong outliers or heavy skew in small samples call for a transformation or a non-parametric test.
A small p-value says the observed difference would be rare if were true; it does not measure how large or important the difference is. Report the confidence interval and an effect size such as Cohen’s (about 0.2 small, 0.5 medium, 0.8 large) alongside it. For tabulated critical values at any α, use the critical value calculator; for the summary statistics themselves, the standard deviation calculator.
Frequently asked questions
What does the t-test tell me?
Whether the difference between a sample mean and a reference value, or between two means, is larger than random sampling variation would typically produce. The p-value measures that.
Should I use Welch’s or Student’s two-sample test?
Welch’s test is the safer default: it does not assume equal variances and loses little when they are equal. Use the pooled test only when equal variances are well justified.
When is a t-test paired?
When each value in one list belongs with one value in the other — the same person before and after, twins, left and right eye. The test then analyses the differences.
One-tailed or two-tailed?
Use two-tailed unless the direction was fixed before seeing the data and a difference in the other direction would be treated like no difference. A one-tailed p-value is half the two-tailed one when t points the expected way.
Why are the Welch degrees of freedom not a whole number?
The Welch–Satterthwaite formula approximates the distribution of the statistic with a t distribution whose df can be fractional. The calculator uses the exact fractional value.
Sources
- NIST/SEMATECH e-Handbook of Statistical Methods, §1.3.5.3 Two-sample t-test for equal means
- NIST/SEMATECH e-Handbook of Statistical Methods, §1.3.5.2 Confidence limits for the mean
- OpenStax, Introductory Statistics 2e, §10.1 Two Population Means with Unknown Standard Deviations
- OpenStax, Introductory Statistics 2e, §10.4 Matched or Paired Samples
- Welch BL (1947), The generalization of “Student’s” problem when several different population variances are involved, Biometrika 34:28–35
Last updated: