T-Test Calculator
A t-test divides a difference in means by its standard error. For one sample, t = (x̄ − μ₀) ÷ (s ÷ √n) with n − 1 degrees of freedom. If t is beyond the critical value for your significance level, the difference is statistically significant. Enter your means, standard deviations and sample sizes to get t.
Last updated by Ultra Calculator
T-Test
How to calculate it
One sample: t = (x̄ − μ₀) ÷ (s ÷ √n) Two samples, Welch: t = (x̄₁ − x̄₂) ÷ √(s₁² ÷ n₁ + s₂² ÷ n₂) Two samples, pooled: t = (x̄₁ − x̄₂) ÷ √[s_p² × (1 ÷ n₁ + 1 ÷ n₂)] Paired: t = d̄ ÷ (s_d ÷ √n)
- x̄, x̄₁, x̄₂
- the sample mean, or the means of groups 1 and 2
- s, s₁, s₂
- the matching sample standard deviations
- n, n₁, n₂
- the sample sizes (for a paired test, n is the number of pairs)
- μ₀
- the hypothesised mean in a one-sample test
- s_p²
- the pooled variance: ((n₁ − 1)s₁² + (n₂ − 1)s₂²) ÷ (n₁ + n₂ − 2)
- d̄, s_d
- the mean and standard deviation of the paired differences
Degrees of freedom are n − 1 for one-sample and paired tests, n₁ + n₂ − 2 for the pooled test, and the Welch-Satterthwaite formula for Welch's test, which usually gives a fraction. In Excel, =T.DIST.2T(ABS(t), df) gives the two-tailed p-value.
In Excel or Google Sheets: =T.DIST.2T(ABS(B1),B2)
Worked example
One-sample test against 68 inches
A sample of 25 heights with mean 70 and s = 4 gives a standard error of 0.8 and t = 2.5 with 24 degrees of freedom. The two-tailed p-value is 0.0197, below 0.05, so the test rejects the null hypothesis at the 5% level: t is beyond the critical value of ±2.064.
| Test Type | One-sample t-test |
|---|---|
| Alternative Hypothesis | Two-tailed (≠) |
| Significance Level (α) | 0.05 (5%) |
| Sample Mean (x̄₁) | 70 |
| Sample Standard Deviation (s₁) | 4 |
| Sample Size (n₁) | 25 |
| Hypothesised Mean (μ₀) | 68 |
| Test | One-Sample T-Test |
|---|---|
| t Statistic | 2.5 |
| P-Value | 0.0197 |
| Significant? | Yes |
| Conclusion | Reject the null hypothesis at the 5% level |
| Degrees of Freedom | 24 |
| Critical t Value | ±2.064 |
| Significance Level (α) | 0.05 (5%) |
| Standard Error | 0.8 |
| Confidence Interval | (68.3489, 71.6511) |
| Confidence Level | 95% |
| Alternative Hypothesis | Two-tailed (≠) |
How to use this calculator
- Choose the Test Type, the Alternative Hypothesis and the Significance Level (α).
- One-sample test: enter the Sample Mean, Sample Standard Deviation, Sample Size and the Hypothesised Mean.
- Two-sample test: enter group 1 in the first three boxes and group 2 in the Group 2 boxes, then choose whether to assume equal variances.
- Paired test: enter the Mean of the Differences, the Standard Deviation of the Differences and the number of pairs in Sample Size (n₁).
- Read the t Statistic, the P-Value and the Conclusion. For a one-tailed test the p-value counts only the direction you chose, so a t pointing the other way gives a large p-value.
Frequently asked questions
How do you calculate a t-test by hand?
For a one-sample test, divide the sample standard deviation by √n to get the standard error, then divide the difference between the sample mean and the hypothesised mean by it. With x̄ = 70, μ₀ = 68, s = 4 and n = 25, the standard error is 0.8 and t = 2 ÷ 0.8 = 2.5, with 24 degrees of freedom.
Which t-test should I use?
Use a one-sample test to compare one mean with a fixed value. Use a two-sample test for two separate groups, such as two classes. Use a paired test when each value in one set matches a value in the other, such as the same people measured before and after.
Should I assume equal variances?
Welch's test does not need equal variances and is the safer default, especially when the standard deviations or group sizes differ. The pooled test assumes equal variances and is slightly more powerful when that holds. If unsure, leave the default, which is Welch's.
What does the p-value mean?
It is the probability, if the null hypothesis were true, of a t at least as extreme as yours in the direction (or directions) your alternative hypothesis names. A p-value below α counts as significant. The calculator works it out from the t distribution for your degrees of freedom and tails.
Should I use a one-tailed or two-tailed test?
Use two-tailed unless you had a good reason, before seeing the data, to care about only one direction. A one-tailed test puts all of α in one tail, so it needs a smaller t in that direction and does not count an effect in the other direction as evidence.
How do I check the p-value in Excel?
Use =T.DIST.2T(ABS(t), df) for a two-tailed test, =T.DIST.RT(t, df) for a right-tailed test and =T.DIST(t, df, TRUE) for a left-tailed test, with t and df from this calculator. Excel takes degrees of freedom as a whole number, so for Welch's test, whose degrees of freedom are usually a fraction, Excel's figure can differ slightly from the one here.
Learn more
The t distribution
When the standard deviation comes from the sample, the test statistic follows a t distribution, which has heavier tails than the normal curve. The fewer the degrees of freedom, the heavier the tails and the larger the critical value: 2.064 for a two-tailed 5% test with 24 degrees of freedom, against 1.960 for z.
Degrees of freedom
Degrees of freedom count the independent pieces of information behind the standard deviation. A one-sample or paired test has n − 1. The pooled two-sample test has n₁ + n₂ − 2, and Welch's test uses a formula that gives a value between the smaller n − 1 and n₁ + n₂ − 2.
Statistical and practical significance
A significant result does not show that the difference is large or important. With big samples, tiny differences become significant, so report the mean difference and its confidence interval as well.
- Checking whether a sample mean differs from a target or specification
- Comparing the average results of two groups, such as two teaching methods
- Testing before-and-after measurements on the same people or items
- Re-running a t-test from the means and standard deviations reported in a paper
- Statistics coursework and exam practice
Using a two-sample test on paired data
If the same people are measured twice, work out each person's difference and use the paired test. Treating the two sets as independent throws away the information in the pairing and often hides the effect.
Choosing the tail after seeing the data
Switching to a one-tailed test because t came out on that side halves the p-value after the fact. Decide the direction before you look at the results, or use the two-tailed test.
Reading the p-value as the chance the null hypothesis is true
A p-value of 0.02 means a t this extreme would turn up 2% of the time if the null hypothesis were true. It is not a 2% chance that the null hypothesis is true.
Entering the variance as the standard deviation
The boxes expect standard deviations. If a paper reports variances, take the square root first.
Reading "fail to reject" as proof of no difference
A non-significant result means the data are compatible with no difference, not that there is none. A small sample can easily miss a real effect.
- Plan the size of each group in advance with the power option of the sample size calculator.
- For a confidence interval around a single mean at any level, use the confidence interval calculator.
- For counts in categories rather than means, use the chi-square calculator.
Methodology and sources
The calculator computes t and its degrees of freedom with the standard formulas, keeping Welch's degrees of freedom unrounded, as R and Python's SciPy do. The p-value comes from the t distribution, worked out with the regularised incomplete beta function, and the critical value is the matching t quantile, both accurate to well beyond the decimals shown. A two-tailed p-value counts both tails. A one-tailed p-value counts only the tail your alternative names, so a t pointing the other way gives a p-value above 0.5. The result is significant when the p-value is below α, which is the same as t falling beyond the critical value. The confidence interval for one-sample and paired tests is two-sided at 1 − α. The test assumes independent observations (independent pairs, for a paired test) and roughly normal data (the differences, for a paired test), or samples large enough for the means to be close to normal.