T-Test Calculator
Paste your data or type summary numbers, pick the test, and read t, the p-value and the confidence interval.
https://flxcode.com/t-test-calculator/
Paste a column from Excel, Google Sheets or a CSV file, or type numbers separated by spaces, commas or new lines. A header word is ignored.
Same format as sample 1.
Example Welch's t-test
p-value (Welch's t-test, two-tailed)
Sample 1: Read 8 numbers. Sample 2: Read 9 numbers.
Welch's test does not assume the two groups have the same spread, and it loses almost nothing when they do. That is why it is the default. Pick Student's pooled test only if you have a reason to assume equal variances.
With fewer than 15 values in a sample the t-test leans on the data being roughly bell-shaped. One outlier can move the result a lot.
Cohen's d of 1.1 is a large effect by Cohen's rough rule of thumb (0.2 small, 0.5 medium, 0.8 large). It does not depend on the sample size, the p-value does.
The alternative hypothesis is that the true means differ. Statistical significance is not the same as an effect that matters.
| Mean of sample 1 (x̄₁) | 80.875 |
|---|---|
| Mean of sample 2 (x̄₂) | 73.7778 |
| Difference (x̄₁ − x̄₂) | 7.09722 |
| Sizes (n₁, n₂) | 8, 9 |
| t statistic | 2.23796 |
| Degrees of freedom | 13.71 |
| p-value (two-tailed) | 0.0423652 |
| Significant at α = 0.05? | Yes, p ≤ α. Reject the null hypothesis. |
| Standard error | 3.17129 |
| 95% confidence interval for the difference in means | 0.28214 to 13.9123 |
| Cohen's d (pooled standard deviation) | 1.1 |
The steps, with your numbers
Sample 1: x̄₁ = 80.875, s₁ = 7.05969, n₁ = 8. Sample 2: x̄₂ = 73.7778, s₂ = 5.86894, n₂ = 9.
Standard error: SE = √(s₁²/n₁ + s₂²/n₂) = √(6.22991 + 3.82716) = 3.17129
Degrees of freedom (Welch-Satterthwaite): df = (s₁²/n₁ + s₂²/n₂)² / ((s₁²/n₁)²/(n₁ − 1) + (s₂²/n₂)²/(n₂ − 1)) = 13.71
t = (x̄₁ − x̄₂) / SE = 7.09722 / 3.17129 = 2.23796
p-value (two-tailed) = 0.0423652 = 2 × P(T ≥ |2.23796|) with 13.71 df
Interval: x̄₁ − x̄₂ ± t* × SE with t* = 2.14899 gives 0.28214 to 13.9123
No ads. No account. Nothing you type or record is uploaded. We count page events with a daily code. Check it. What this tool keeps and sends.
Problem or idea? Email us
Quick start
- Choose one sample, two samples or paired, and raw or summary numbers.
- Paste each group in its own box. The two boxes can have different lengths unless the test is paired.
- The p-value is the headline. t, df, the interval, Cohen's d and the steps are below it.
Worked examples
| Case | Data | t | df | p (two-tailed unless noted) | 95% interval or bound |
|---|---|---|---|---|---|
| Two groups, Welch (the default) | Scores 78 84 69 91 88 75 82 80 and 72 70 85 66 74 79 68 73 77 | 2.238 | 13.71 | 0.0423652 | 0.28214 to 13.9123 |
| Same data, Student pooled | The same two groups with equal variances assumed | 2.264 | 15 | 0.0388453 | 0.414865 to 13.7796 |
| Spreads far apart, Welch | 5 values near 10 and 10 values from 5 to 17 | -0.7182 | 9.17 | 0.490551 | -3.72687 to 1.92687 |
| One sample, right-tailed | 10 bag weights against a label of 500 g | 2.635 | 9 | 0.0135692 | 501.369 and up (no upper limit) |
| Paired, before and after | 8 pairs of readings, 142 138 150 … and 136 135 141 … | 4.919 | 7 | 0.00171491 | 2.85627 to 8.14373 |
| Summary numbers only | n = 25, mean 52.4, s = 8.1 against n = 30, mean 47.9, s = 10.3 | 1.813 | 52.85 | 0.075514 | -0.478765 to 9.47876 |
The right-tailed bag example shows a one-sided bound because a one-tailed test only limits the mean from one side.
The formulas
t = (x̄₁ − x̄₂) / SE. For Welch, SE = √(s₁²/n₁ + s₂²/n₂) and the degrees of freedom are (s₁²/n₁ + s₂²/n₂)² / ((s₁²/n₁)²/(n₁−1) + (s₂²/n₂)²/(n₂−1)). For Student, SE = s_p √(1/n₁ + 1/n₂) with the pooled s_p and df = n₁ + n₂ − 2. One-sample and paired tests use SE = s / √n and df = n − 1, with the paired test run on the differences.
The p-value is a tail area of Student's t distribution, computed with the incomplete beta function, so tiny values keep their digits (a p of 1e-12 shows as 1e−12, not 0). To look up a p-value for a t you already have, use the p-value calculator. To get an interval for one mean without a test, use the confidence interval calculator. For three or more groups use the ANOVA calculator, and for counts in a table the chi-square test calculator.
Numbers this uses
- Default α is 0.05. The common convention, editable in the tool.
- Default test is Welch's two-sample. It does not assume equal variances.
- Accuracy is matches scipy.stats to 8 digits or better. Checked on 12 datasets, including a p-value near 1e-12.
- Limit is 100,000 numbers per box. Kept low so the page stays quick on a phone.
Limits
The null hypothesis is always "no difference" (or the mean equals μ₀ for one sample): you cannot test for a difference of 5, for example. There is no normality test, no check that the variances are equal, no rank-based test and no more than two groups (use ANOVA for three or more). If the two boxes are paired, they must have the same length.
In Excel and Google Sheets
Type sample 1 (78, 84, 69, 91, 88, 75, 82, 80) in A1:A8 and sample 2 (72, 70, 85, 66, 74, 79, 68, 73, 77) in B1:B9. The formulas below work the same in both programs: every function name was checked against Google's function list.
| Task | Formula | Result |
|---|---|---|
| Welch's t-test, two-tailed p-value | =T.TEST(A1:A8,B1:B9,2,3) | 0.0423652 |
| Student's pooled t-test, two-tailed p-value | =T.TEST(A1:A8,B1:B9,2,2) | 0.0388453 |
| p-value from a t statistic (here t and its degrees of freedom from the table above) | =T.DIST.2T(ABS(2.23796),13.7137) | 0.0423652 |
The last argument of T.TEST is the type: 1 paired, 2 two samples with equal variance, 3 two samples with unequal variance (Welch). T.TEST gives only the p-value, not t or the confidence interval. For one sample against a fixed mean there is no T.TEST: work out t = (mean − μ₀) / (s / √n) and use T.DIST.2T.
You can also paste the column into the box above, or open an .xlsx or .csv file with the Open button, and use Download .xlsx to get these formulas filled in with your own numbers.
FAQ
Which t-test do I need?
Use one sample to compare one group with a known or claimed value, like bags that should weigh 500 g. Use two samples to compare the means of two separate groups, such as two classes. Use paired when each value in one box belongs to a value in the other: the same people before and after, or matched twins.
Welch or Student?
Welch is the default. It does not assume the two groups have the same spread, and it loses almost nothing when they do. Student's pooled test assumes equal variances. On the default data they give p = 0.0423652 and 0.0388453, close because the spreads are similar. With very different spreads and unequal sizes they can disagree a lot, and Welch is the one to trust. Welch's degrees of freedom are usually a fraction (13.71 here), and the tool uses that value as it is, without rounding down.
One-tailed or two-tailed?
Two-tailed asks whether the means differ in either direction, and is the usual choice. Right-tailed asks whether mean 1 is greater than mean 2 (or the mean is above μ₀), and left-tailed whether it is smaller. Pick the direction before you look at the data. For the bag example, a right-tailed test gives p = 0.0135692.
How do I read the confidence interval?
It is a range for the true difference between the two means (for a one-sample test, for the mean itself). The default example gives 0.2821 to 13.91. If a two-tailed interval at 95% excludes 0, the two-tailed p is below 0.05. For a one-tailed test the tool shows a one-sided bound instead, with no limit on the other side.
What is Cohen's d?
The difference in means divided by the pooled standard deviation, so it says how big the difference is in units of spread. The default example has d = 1.1. By the usual rule of thumb 0.2 is small, 0.5 medium and 0.8 large. A big sample can give a tiny p for a tiny d, so look at both.
Can I use summary numbers instead of raw data?
Yes. Switch to "Summary numbers" and enter each sample's size, mean and standard deviation (the sample one, dividing by n − 1). For a paired test enter the number of pairs and the mean and standard deviation of the differences. The summary example here gives p = 0.075514.
More from FLXCode
- P-Value Calculatorp-value from a z, t, chi-square or F statistic, one or two tailed, with the tails shown.
- ANOVA CalculatorOne-way (classic and Welch), two-way, Levene and Tukey HSD from pasted columns, with effect sizes.
- Confidence Interval CalculatorConfidence interval for a mean (z or t) or a proportion, at 90, 95, 99 or your own level.
- Standard Deviation CalculatorPaste your numbers and get the sample and population standard deviation, with the steps shown.