statcompute

Hypothesis tests

T-Test Calculator

Compare two means — or one mean against a target — and find out whether the difference is larger than sampling noise can comfortably explain.

Updated August 2026Runs in your browser — nothing is uploadedVerified against R

Two independent groups of different subjects — the most common case.

One value per line, or separated by commas, tabs or spaces. A header row is ignored.
One value per line, or separated by commas, tabs or spaces. A header row is ignored.
Pick this before seeing the results, not after.
Conventionally 0.05. Decide before you look at the data.
Leave unticked for Welch's test, which does not assume equal variances and is what R and most software default to.

The calculation runs in your browser, so this box needs JavaScript. The formula, the worked example and the interpretation below do not.

01

How to read this result

The headline number is the p-value: the probability of seeing a difference at least this large if the two populations really had the same mean. Small p, awkward for the null hypothesis.

What it does not mean. p = 0.03 is not a 3% chance that the null is true, and it is not a 97% chance your hypothesis is right. It is a statement about the data under an assumption, not about the assumption given the data.

Read the confidence interval next, and preferably first. It gives the range of differences consistent with your data. A difference of 2.1 units with an interval from 1.4 to 2.9 is a useful finding; a difference of 2.1 with an interval from −0.1 to 4.3 is a shrug, even if the p-value scrapes under 0.05.

Then look at Cohen's d. With a large enough sample, a difference far too small to matter will still be significant. d expresses the gap in standard deviations, which does not shrink as the sample grows: 0.2 is small, 0.5 medium, 0.8 large — conventions, not laws.

A large p-value is not evidence of no difference. It usually means the study was too small to detect the difference that is there. Statistical power is how you tell those two situations apart, and it should be checked before the study rather than after.

±-1.96±1.962.5%2.5%test statistic
The shaded tails hold 5% of the distribution between them. A statistic landing there is what “significant at α = 0.05” means — nothing more and nothing less.
02

The formula

Two independent samples (pooled)

t=x¯1x¯2sp1n1+1n2sp=(n11)s12+(n21)s22n1+n22
x¯1,x¯2
the two sample means
s1,s2
the two sample standard deviations
n1,n2
the two sample sizes
sp
the pooled standard deviation — a weighted average of the two

Degrees of freedom: n₁ + n₂ − 2.

Welch's version, when the variances differ

t=x¯1x¯2s12n1+s22n2ν=(s12n1+s22n2)2(s12/n1)2n11+(s22/n2)2n21

The Welch-Satterthwaite degrees of freedom ν are usually fractional. This is the default here and in R, because it costs almost nothing when the variances are equal and rescues the test when they are not.

One sample and paired

t=x¯μ0s/n
x¯
the sample mean — for a paired test, the mean of the differences
μ0
the hypothesised value, usually 0 for a paired test
s
the sample standard deviation of those values

Degrees of freedom: n − 1. A paired test is a one-sample test on the differences, which is why the two formulas are the same.

03

Worked example

Comparing the yield of two maize varieties

Eight plots are sown with variety A and eight with variety B, and the yield of each plot is recorded in tonnes per hectare. Variety B looks better — but eight plots is not many, and plot yields vary a lot on their own. Is the gap real?

Variety A: 12.1, 13.4, 11.9, 14.2, 12.8, 13.9, 12.5, 13.1 Variety B: 14.8, 15.2, 14.1, 16.0, 15.5, 14.6, 15.9, 15.1

  1. Take both means.
    A: 103.9 / 8 = 12.9875 B: 121.2 / 8 = 15.15
  2. Take both standard deviations.
    s₁ = 0.82191 s₂ = 0.64807
  3. Pool them, weighting by degrees of freedom. With equal group sizes this is just the average of the two variances.
    sₚ² = (0.67554 + 0.42000) / 2 = 0.54777 → sₚ = 0.74011
  4. Compute the standard error of the difference.
    SE = 0.74011 × √(1/8 + 1/8) = 0.74011 × 0.5 = 0.37006
  5. Divide the difference by the standard error.
    t = (12.9875 − 15.15) / 0.37006 = −2.1625 / 0.37006 = −5.8437
  6. Look t up against the t distribution on n₁ + n₂ − 2 = 14 degrees of freedom, two-tailed.
    p = 0.0000427
  7. Express the gap as an effect size.
    d = −2.1625 / 0.74011 = −2.92
t −5.84df 14p 0.00004395% CI for the difference −2.96 to −1.37Cohen's d −2.92

The interval says variety B out-yields A by somewhere between 1.4 and 3.0 tonnes per hectare. That range — not the p-value — is what a decision about which variety to sow should be based on.

Checked against R's t.test(x, y, var.equal = TRUE).

The calculator above is loaded with these numbers by the Load the worked example button.

04

Assumptions, and when to use something else

A t-test asks four things of your data, in rough order of how much they matter.

  1. The observations are independent. Each plot, patient or visitor contributes one value that does not depend on the others. This is the assumption that cannot be repaired after the fact: clustered or repeated measurements analysed as if independent produce p-values that are far too small.
  2. The right test for the design. Paired data analysed as two independent samples throws away the pairing and loses power; independent data analysed as paired is simply wrong.
  3. Roughly normal, or a large enough sample. The test needs the sample mean to be approximately normal, which the central limit theorem provides even for skewed data once n is moderate. It matters most below about 15 per group, and it matters most of all when the data are skewed and the groups are unequal in size.
  4. Comparable spread, for the pooled version only. Welch's test drops this assumption entirely, which is why it is the default here.
  • Data are skewed or have outliersMann-Whitney U testCompares distributions using only the ordering of the values, so a single extreme observation cannot dominate it.
  • Paired data, not normally distributedWilcoxon signed-rank testThe rank-based version of the paired t-test; assumes only that the differences are symmetric.
  • Three or more groupsOne-way ANOVATests all the group means at once. Running several t-tests instead inflates the false-positive rate — three tests at α = 0.05 carry about 14% risk, not 5%.
  • The outcome is a proportion, not a measurementz-test for proportionsConverted or not, passed or failed — counts need a proportion test rather than a test of means.
  • You want to know how many observations you needSample size calculatorWork out n before you collect data, from the difference you want to be able to detect.
05

Questions people ask

What is the difference between a paired and an unpaired t-test?

A paired test is for the same subjects measured twice — before and after, left and right, matched pairs. It analyses the differences within each pair, which removes the variation between subjects and usually makes the test far more sensitive. An unpaired (independent) test is for two separate groups of subjects. Using the wrong one is a real error: pairing that exists and is ignored wastes power, and pairing claimed where none exists produces a p-value that means nothing.

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

Welch's, in almost every case. It does not assume the two groups have equal variances, it costs a negligible amount of power when they do, and it is the default in R and most modern software. The pooled test is worth using only when you have a genuine reason to believe the variances are equal — and testing for that first, then choosing, is itself a mild form of data-dependent analysis.

What does a negative t value mean?

Only that the first mean is smaller than the second. The sign follows the order you entered the groups in, and flipping them flips the sign without changing anything else. For a two-tailed test the p-value depends on |t|, so the sign does not affect significance at all — it only tells you the direction.

How many observations do I need for a t-test?

There is no minimum, but there is a cost: with very small samples the test has little power, so a real difference will often be missed. As a rough guide, detecting a medium effect (d = 0.5) with 80% power takes about 64 per group; a large effect (d = 0.8) takes about 26. The sample size calculator works it out for your case, and power shows what you get from the n you have.

Can I run a t-test on Likert-scale responses?

It is common and it is contested. Strictly, a 1–5 agreement scale is ordinal, and the distance from 1 to 2 need not equal the distance from 4 to 5. In practice t-tests on Likert averages over several items behave well; on a single item with a small sample, the Mann-Whitney test is the safer choice and gives up little.

What is a good t value?

There is no such thing on its own — t is meaningful only against its degrees of freedom. On 10 degrees of freedom, |t| above 2.23 is significant at 0.05; on 100 it takes only 1.98. That is what the calculator's critical value line shows, and it is why the p-value rather than t is the number to report.