CompoundPage

T Test Calculator

Paste your data or enter the means, SDs and sample sizes. The t test calculator gives the t statistic, the degrees of freedom, the p-value for every tail, a confidence interval and the decision.

Raw data only. Separate with commas, spaces or new lines; a pasted spreadsheet column works. For a paired test, in the same subject order as sample 2.

Raw data, two-sample and paired tests. Not used by the one-sample test.

Summary statistics only. For a paired test, the mean of the differences.

The sample SD (divided by n - 1). For a paired test, the SD of the differences.

For a paired test, the number of pairs.

Summary statistics, two-sample tests only.

Summary statistics, two-sample tests only.

Summary statistics, two-sample tests only.

The value under the null hypothesis: the mean for a one-sample test, the difference for the others (almost always 0).

All three p-values are shown; this picks the one the decision uses.

p-value (two-tailed)0.0028

t statistic t = (d̄ - hypothesized) / standard error = (1.58 - 0) / (1.23 / √10) = 1.58 / 0.38896. A paired test is a one-sample test on the differences.
4.0621
Degrees of freedom n - 1 = 10 - 1, where n is the number of pairs.
9
p-value, two-tailed P(|T| ≥ 4.0621): a difference this large in either direction.
0.0028
p-value, one-tailed (greater) P(T ≥ 4.0621), for the alternative that the mean difference is greater than 0.
0.0014
p-value, one-tailed (less) P(T ≤ 4.0621), for the alternative that the mean difference is less than 0.
0.9986
Critical t at alpha = 0.05 Reject when |t| is larger. From the t table at 9 df, column 0.975.
±2.2622
Decision p = 0.0028 is below 0.05. A mean difference this far from 0 would be rare if the true mean difference were 0. It says nothing about whether the difference is large enough to matter.
Reject the null hypothesis
Mean difference Standard error 0.38896.
1.58
95% confidence interval 1.58 ± 2.2622 × 0.38896. It excludes 0, which agrees with the two-tailed test at alpha = 0.05.
0.700114 to 2.45989
Effect size (Cohen's d) The mean difference over the SD of the differences (d_z). Unlike t, it does not grow with the sample size.
1.28
The same data, unpaired Welch's two-sample test on the same numbers, ignoring which values belong together. Pairing removes the subject-to-subject variation, which is why the paired test is usually more sensitive.
t = 1.8608, df = 17.7765, two-tailed p = 0.0794
The samples
nMeanSDStandard error
Sample 1102.332.002250.63317
Sample 2100.751.789010.56573
Differences (1 - 2)101.581.230.38896
  • A t test assumes independent observations and roughly normal data, or a sample large enough (around 30 or more per group) for the mean to be close to normal anyway. It is sensitive to outliers.
  • The p-value is the chance of a result at least this extreme if the null hypothesis were true. It is not the chance that the null hypothesis is true.

How the T Test Calculator works

A t test asks whether a difference in means is bigger than the noise in the data would produce by chance. It divides the difference by its standard error, and reads the result, t, against Student's t distribution with the right degrees of freedom. A large t gives a small p-value.

Which t test. There are three, and picking the wrong one is the commonest mistake. A one-sample t test compares one mean with a fixed value: t = (x̄ - μ₀) / (s / √n), on n - 1 degrees of freedom. A paired t test is for the same subjects measured twice, or matched pairs. It takes the difference within each pair and runs a one-sample t test on the differences against 0.

Picking the mode. Choose the paired t test calculator mode for before-and-after data, the one sample t test calculator mode to compare a mean with a target, and either two sample t test calculator mode for two separate groups. The formula for a t test is the same shape every time: the difference, minus what the null hypothesis expects, over its standard error.

Two independent groups. A two-sample t test compares the means of two separate groups. Welch's version, t = (x̄₁ - x̄₂) / √(s₁²/n₁ + s₂²/n₂), does not assume the groups have equal variances. Its degrees of freedom come from the Welch-Satterthwaite formula and are usually not a whole number. The pooled version, Student's original, assumes equal variances, pools them into one SD and uses n₁ + n₂ - 2 degrees of freedom. Welch's is the safer default.

The default example is Student's. W. S. Gosset published the t test in 1908 under the name Student. One of his examples was Cushny and Peebles' measurements of the extra hours of sleep 10 patients got from each of two drugs. With those as sample 1 and sample 2, the paired test gives a mean difference of 1.58 hours, t = 4.0621 on 9 degrees of freedom, and a two-tailed p of 0.0028. The 95% confidence interval for the difference runs from 0.70 to 2.46 hours. Run the same numbers as two independent groups and Welch's test gives t = 1.8608 on 17.776 df and p = 0.0794, not significant at 0.05. The patients differ from each other far more than the drugs do, and only the paired test removes that.

From summary statistics. Switch "Enter" to summary statistics and the default numbers are the NIST/SEMATECH e-Handbook's two-sample example: miles per gallon for 249 US cars (mean 20.14458, SD 6.41470) and 79 Japanese cars (mean 30.48101, SD 6.10771). The pooled test gives t = -12.62059 on 326 degrees of freedom with a pooled SD of 6.34260, as the handbook prints, against a critical value of 1.9673. Welch's test on the same numbers gives t = -12.9463 on 136.875 df.

Reading the p-value. The two-tailed p-value counts a difference in either direction. A one-tailed test counts only the direction you chose before looking at the data, and its p-value is half the two-tailed one when t points that way. The confidence interval says the same thing as the two-tailed test: it excludes the hypothesized value exactly when p is below alpha. Cohen's d gives the size of the difference in standard deviations, which the p-value does not.

The p-values here come from the exact t distribution, computed through the regularized incomplete beta function. They match printed t tables: at 10 degrees of freedom the two-tailed 5% critical value is 2.228, and at 1 degree of freedom it is 12.706.

T Test Calculator FAQ

How do you calculate a t test?

Divide the difference in means by its standard error. For one sample, t = (x̄ - μ₀) / (s / √n) on n - 1 degrees of freedom. Then find the p-value from the t distribution. The paired sleep data gives t = 1.58 / (1.23 / √10) = 4.0621 on 9 df, p = 0.0028.

Should I use Welch's t test or the pooled t test?

Welch's, unless you have good reason to think the two groups have the same variance. It loses little when the variances are equal and stays accurate when they are not, especially with unequal sample sizes. The pooled test is shown alongside so you can compare.

When do I use a paired t test?

When each value in one sample belongs with one value in the other: the same people before and after, two treatments on the same subjects, or matched pairs. Treating paired data as two independent groups throws away the pairing and usually gives a much larger p-value.

What are the degrees of freedom for a t test?

n - 1 for one-sample and paired tests (n is the number of pairs), n₁ + n₂ - 2 for the pooled two-sample test, and the Welch-Satterthwaite value, usually not a whole number, for Welch's test.

Is my result significant?

It is significant at your alpha if the p-value is below it, which is the same as |t| exceeding the critical value. At 9 degrees of freedom the two-tailed 5% critical value is 2.262, so t = 4.0621 is significant. Significance does not say the difference is large; the confidence interval and Cohen's d do.

Related calculators

Embed this calculator
<div id="compoundpage-t-test-calculator"></div>
<script src="https://compoundpage.com/embed/t-test-calculator.js" async></script>

The same calculation as JSON