T Test Calculator

T Test Calculator

Run a one sample, two sample or paired t test from summary statistics or raw data. Welch’s test is the default for two groups, with the pooled test as an option. You get t, the p value, the critical t, a decision in plain words, the confidence interval and Cohen’s d.

Every figuretap a card to copy its value

The t distribution for this test

The same test at other significance levels

t = (estimate − hypothesized value) ÷ standard error. Welch keeps the two variances separate and uses Welch Satterthwaite degrees of freedom; pooled combines them, with n₁ + n₂ − 2. Paired works on the differences, first minus second. Assumes independent random samples and roughly normal data or large samples. The CSV, image and printed report contain the values you entered, nothing preloaded.

How to use this tool

Pick the test. Two independent samples compares separate groups, such as two classes or two machines; paired is for the same people or items measured twice; one sample compares a mean with a fixed value such as a target weight. Type the mean, standard deviation and size of each group, or switch to raw data and paste the numbers, then set the alternative and the significance level.

The input people most often get wrong is the standard deviation. It must be the sample standard deviation of the individual values, calculated with n − 1, not the standard error of the mean. A standard error is already divided by √n, so entering it makes t √n times too large: five and a half times with 30 values. For paired data the calculator takes first minus second, so a fall from before to after gives a positive mean difference.

What the calculation is doing

Every t test has the same shape: t = (estimate − hypothesized value) ÷ standard error. The estimate is a mean, a mean difference or a difference between two means, and the standard error is how much it would vary from one sample to the next. So t counts standard errors: 3.5 is a long way out, 0.7 is ordinary sampling noise.

For one sample the standard error is s ÷ √n with n − 1 degrees of freedom, and a paired test does the same on the differences. For two samples Welch's test uses √(s₁² ÷ n₁ + s₂² ÷ n₂) with degrees of freedom from the Welch Satterthwaite equation, ν = (s₁² ÷ n₁ + s₂² ÷ n₂)² ÷ [(s₁² ÷ n₁)² ÷ (n₁ − 1) + (s₂² ÷ n₂)² ÷ (n₂ − 1)], usually not a whole number. The pooled test combines the variances into sₚ² = ((n₁ − 1)s₁² + (n₂ − 1)s₂²) ÷ (n₁ + n₂ − 2) and uses sₚ × √(1 ÷ n₁ + 1 ÷ n₂) with n₁ + n₂ − 2 degrees of freedom.

The p value is the area of the t distribution beyond the observed t, in one tail or both, and the critical t cuts off an area equal to α, so p ≤ α and t past the critical value are the same decision. The interval, estimate ± critical t × standard error, excludes the hypothesized value exactly when the two tailed test rejects. Cohen's d divides the difference by the pooled standard deviation, or by the standard deviation of the differences for paired data. Tail areas come from the incomplete beta function, and when p is too small to store the calculator works on a log scale rather than showing zero.

Left, systolic blood pressure of ten people before and after a change of diet, each person drawn as a line from before to after, with the before readings spread from 118 to 161 mmHg and every line falling by 1 to 8, beside a strip of the ten falls with their mean of 4.4. Right, the same numbers as 95% intervals for the fall: tested as two independent groups the standard error is 5.95, the interval runs from −8.1 to 16.9 across zero, t = 0.74 and p = 0.469; tested as pairs the standard error is 0.70, the interval runs from 2.8 to 6.0, t = 6.26 and p = 0.000147
Nothing about the data changes between the two panels. The paired test stops comparing different people with each other, and the standard error falls from 5.95 to 0.70, 8.5 times smaller.

Paired or independent, Welch or pooled: why the choice matters

Ten people have their blood pressure taken before and after a change of diet. Their before readings run from 118 to 161 mmHg, but each person falls by only 1 to 8, an average of 4.4. Tested as two independent groups, that small shift is buried in the spread between people: the standard error is 5.95, t = 0.74 and p = 0.469. Tested as pairs, each person is compared with themselves, the standard error drops to 0.70, t = 6.26 and p = 0.000147. Same numbers, opposite conclusions, and only the paired test is right.

Pooling assumes both populations share one variance. When they do not and the group sizes differ, the pooled test stops meaning what it says. In 100,000 simulated tests with equal true means, 10 values with a standard deviation of 3 against 40 with a standard deviation of 1 gave a pooled false alarm rate of 25.7% at the 5% level, while Welch held at 5.0%. Swap which group is noisy and the pooled test turns timid, rejecting 0.1% of the time. With equal sizes and spreads both gave 5.1%, so Welch costs almost nothing, which is why it is the default here and in R.

A small p value is not a large effect either. A sample of 30 with a mean IQ of 104.2 and a standard deviation of 14.1 gives p = 0.114 against 100; the same mean from 120 people gives p = 0.00144. Cohen's d is 0.298 both times, because only the precision changed. Report the interval and d with the p value.

Critical values of t

The value t must pass to reject, by degrees of freedom and significance level. For Welch's fractional degrees of freedom the calculator gives the exact value.

Degrees of freedom0.05 one tailed
0.10 two tailed
0.025 one tailed
0.05 two tailed
0.01 one tailed
0.02 two tailed
0.005 one tailed
0.01 two tailed
0.0005 one tailed
0.001 two tailed
16.31412.70631.82163.657636.619
22.9204.3036.9659.92531.599
32.3533.1824.5415.84112.924
42.1322.7763.7474.6048.610
52.0152.5713.3654.0326.869
61.9432.4473.1433.7075.959
81.8602.3062.8963.3555.041
101.8122.2282.7643.1694.587
121.7822.1792.6813.0554.318
151.7532.1312.6022.9474.073
201.7252.0862.5282.8453.850
301.6972.0422.4572.7503.646
601.6712.0002.3902.6603.460
1001.6601.9842.3642.6263.390
infinite, the z value1.6451.9602.3262.5763.291

A worked example you can check on paper

The default figures are from Penn State's STAT 415 course: fastest speed ever driven, 105.5 mph for 34 men (s = 20.1) and 90.9 mph for 29 women (s = 12.2). By Welch, s₁² ÷ n₁ = 404.01 ÷ 34 = 11.8826 and s₂² ÷ n₂ = 148.84 ÷ 29 = 5.1324, so the standard error is √17.0150 = 4.1249 and t = 14.6 ÷ 4.1249 = 3.5395. The degrees of freedom are 17.0150² ÷ (11.8826² ÷ 33 + 5.1324² ÷ 28) = 289.51 ÷ 5.2195 = 55.47. The two tailed critical t at α = 0.05 is 2.004, the p value is 0.00082, and the 95% interval is 14.6 ± 2.0037 × 4.1249 = 6.34 to 22.86 mph. With a pooled standard deviation of √((33 × 404.01 + 28 × 148.84) ÷ 61) = 16.94, Cohen's d = 0.862. The course's hand working gives t = 3.54, r = 55.5 rounded down to 55 degrees of freedom, and P = 0.0008.

A paired check from the same course: two labs measure cholesterol in 10 blood samples, mean difference −14.4, standard deviation 6.77. The standard error is 6.77 ÷ √10 = 2.1409, so t = −6.726 with 9 degrees of freedom, beyond the ±3.25 critical values at α = 0.01. The 95% interval is −19.243 to −9.557, as in the course's Minitab output.

Mistakes that catch people out

Entering the standard error as the standard deviation. Software output often lists both. The standard error is s ÷ √n, and using it inflates t by √n, turning noise into a significant result.

Running paired data as two groups. Before and after readings on the same people belong together: the blood pressure example gives p = 0.469 unpaired and 0.000147 paired.

Choosing one tailed after seeing the data. Two classes averaging 78.4 and 72.9 give a two tailed p of 0.0638, and 0.0319 one tailed. Pick the alternative before the data arrive, or the real error rate is double the stated one.

Reading "do not reject" as "no difference". The IQ sample of 30 does not reject 100, but its 95% interval, 98.9 to 109.5, also allows a real gain of 9 points. The study was simply too small.

Pooling by habit. A noisy group of 12 (mean 24.3, s 5.6) against a steady group of 40 (mean 21.9, s 2.1) gives p = 0.0277 pooled but 0.172 by Welch, because pooling borrows the small spread of the big group.

Popular calculations

Each opens the calculator with those figures filled in. Tests are two tailed at α = 0.05 and two sample tests use Welch's method unless marked. The NIST and Penn State examples are the published ones used to check the tool.

Two sample t tests

Paired t tests, before and after

One sample t tests

How this was checked

The NIST/SEMATECH handbook's two sample example, US against Japanese cars with the pooled test, gives t = −12.62059, a pooled standard deviation of 6.34260, 326 degrees of freedom and a critical value of 1.9673, matching every printed figure. Its one sample example, run from the six figure mean and standard deviation the handbook prints, gives t = 2,611.26 against the published 2611.284, the same critical value of 1.9723, and an interval of 9.258241 to 9.264679 against the published 9.258242 to 9.264679. Penn State's Welch, paired and one sample examples, including its quiz scores entered as raw data, were all reproduced.

The p values were then checked by numerical integration of the t density, which shares no code with the incomplete beta function. Across 416 combinations of t and degrees of freedom from 1 to 10,000, including fractions, the two agreed to 1.4 × 10⁻¹¹, and SciPy agreed as closely. All 39 critical values tested matched the NIST table. Every address above was opened and checked for a distinct title, the right canonical address and a drawn chart; layout and exports were checked at eight widths from 320 to 1,280 pixels.

Common questions

What is a t test used for?

To decide whether a mean differs from a fixed value, or two means differ from each other, when the spread has to be estimated from the data. The difference is divided by its standard error to give t, which is compared with the Student t distribution to get a p value.

What is the difference between Welch's t test and Student's t test?

Student's two sample test pools the two standard deviations, which assumes equal variances. Welch's keeps them separate and adjusts the degrees of freedom. With equal variances they agree closely; with unequal ones Welch's keeps the error rate near the stated level and the pooled test may not. R uses Welch's unless told otherwise.

When should I use a paired t test?

When each value in one set belongs with one in the other: the same person before and after, one sample measured by two labs, twins, left and right. The test works on the differences, which removes the variation between subjects. For separate people or items, use the two sample test.

What does the p value actually mean?

The probability of a t at least as extreme as the one observed if the null hypothesis were true. A p value of 0.03 is not a 3% chance that the null hypothesis is true, and it says nothing about how large the difference is.

Should I use a one tailed or a two tailed test?

Two tailed, unless you had a firm reason before collecting the data to care about one direction only. One tailed halves the p value when the data point the expected way, turning 0.0638 into 0.0319 in the two classes example, which is why it must not be chosen after seeing the results.

What counts as a large Cohen's d?

Cohen suggested 0.2 as small, 0.5 as medium and 0.8 as large, the labels used here. They are rough guides: a small effect across millions of people can matter more than a large one in a lab. Unlike the p value, d does not grow with sample size.

Related Calculators and Reference