Bell Statistics

What is a t-test?

A t-test compares the means of two groups and asks whether the gap between them is larger than sampling noise would ordinarily produce. It works from the sample data alone, using the spread within each group to judge how surprising the difference between them is.

Notation
t
Also called
student's t-test, welch's t-test, two-sample t-test, independent samples t-test
Allon Korem

Written by Allon Korem

Chief Executive Officer

Last updated

In plain English

Two groups produce two averages, and those averages are never identical. The question a t-test answers is whether the gap between them is bigger than the gap you would expect from random assignment alone. It answers it by putting the difference on a scale set by the data's own variability: how many standard errors apart are these two means? That ratio is the t statistic, and everything else is looking up how often a value that extreme occurs when nothing is going on.

The scaling is the whole idea, and it is why a t-test cannot be replaced by eyeballing the difference. A £4 gap in average order value is enormous if orders cluster tightly around £30 and invisible if they range from £5 to £900. Dividing by the standard error makes those two situations comparable, which is what lets one table of critical values serve every experiment ever run. The resulting number is compared against the t-distribution rather than the normal curve, because the spread was estimated from the same small sample rather than known in advance.

There are three tests sharing the name and they are not interchangeable. Student's assumes both groups have the same variance; Welch's does not, and is the correct default for online experiments, where a treatment that changes behaviour usually changes its spread as well. The paired t-test is a different design entirely — it applies when each observation in one group has a partner in the other. Most statistical software still defaults to Student's, which is the single most common way a correct-looking analysis is quietly using the wrong test.

The assumption people worry about is normality, and it is mostly the wrong worry. The test needs the *sampling distribution of the mean* to be roughly normal, not the data — and the central limit theorem delivers that for any reasonable sample size on most real distributions. The familiar "n = 30" threshold is folklore: for mildly skewed data thirty is generous, and for revenue data with a long right tail and a handful of enormous customers, thirty is nowhere near enough and several thousand may not be either. The honest check is whether a few extreme values dominate the mean, and when they do the answer is capping them or switching to a rank-based test.

What the test does not tell you is how big the difference is or whether it matters, and reading a small p as a large effect is the error this whole section exists to prevent. Report the difference in the units the business uses alongside a confidence interval — a t-test that clears significance on a gap of £0.04 has told you something true and useless. We make the longer version of that argument in how to report A/B test results.

The formula

One ratio, computed three slightly different ways depending on the design. In every version the numerator is the difference you care about and the denominator is how much that difference bounces around.

The general form
t = ( observed difference ) / ( standard error of that difference )

Every t-test is this. What changes between them is only how the standard error is built.

Welch's two-sample t-test
t = ( x̄₁ − x̄₂ ) / √( s₁²/n₁ + s₂²/n₂ )

The right default. Each group contributes its own variance, so unequal spread is handled rather than assumed away — see the two-sample t-test calculator.

Student's pooled version
t = ( x̄₁ − x̄₂ ) / ( s_p · √( 1/n₁ + 1/n₂ ) )

Combines both groups into one pooled variance s_p. Slightly more powerful when the variances really are equal, and misleading when they are not.

Welch–Satterthwaite degrees of freedom
df ≈ ( s₁²/n₁ + s₂²/n₂ )² / ( (s₁²/n₁)²/(n₁−1) + (s₂²/n₂)²/(n₂−1) )

Why Welch's df is usually fractional. It is the price of not assuming equal variances, and it is a small one — see degrees of freedom.

Worked example

A checkout redesign is tested on average order value. Control shows a mean of £48.20 with a standard deviation of £31.40 across 4,100 orders; the variant shows £50.05 with a standard deviation of £34.90 across 4,050 orders. The spread is visibly different between the arms, which already rules out the pooled version.

Control
x̄ = £48.20, s = £31.40, n = 4,100
Variant
x̄ = £50.05, s = £34.90, n = 4,050
Observed difference
£1.85 (3.8% relative)
Standard error of the difference
√(31.40²/4100 + 34.90²/4050) = £0.735
Test statistic
t = 1.85 / 0.735 = 2.52
Welch df
≈ 8,040

p = 0.012, two-sided. The 95% confidence interval on the difference runs from £0.41 to £3.29.

Significant, and the interval is what makes it actionable. A gap this large turns up by chance about once in eighty identical experiments where the two checkouts were genuinely equivalent, so the difference is real. But the plausible range runs from £0.41 to £3.29, and those two ends imply very different business cases — at the bottom the redesign barely pays for the engineering time, at the top it is one of the best changes of the year. Two details are worth noticing. The variances differ by more than 10%, so using Student's pooled test here would have quietly overstated the precision. And order value is right-skewed, so it is worth confirming that no single enormous order is driving the £1.85; if one is, the mean is the wrong summary and the conclusion should not survive removing it.

Common misconceptions

You need at least 30 observations per group for a t-test to be valid.
There is no such threshold. The requirement is that the sampling distribution of the mean is approximately normal, and how much data that takes depends entirely on the shape of the underlying distribution. Symmetric, light-tailed data is fine at ten per group; heavily skewed revenue data with occasional enormous values can still misbehave at several thousand. The number to look at is how much a handful of extreme observations move the mean, not n.
Your data has to be normally distributed to use a t-test.
The data does not, the sampling distribution of the mean does — and the central limit theorem generally supplies that even when the raw data looks nothing like a bell curve. Conversion counts, session durations and order values are all non-normal and all routinely analysed this way. What actually breaks a t-test is extreme skew combined with a small sample, not non-normality by itself.
Student's t-test is the standard one, so it is the safe default.
Welch's is the safe default. It does not assume equal variances, and when the variances happen to be equal it costs almost nothing — the loss of power is negligible. Student's, by contrast, produces materially wrong p-values when the groups differ in spread and the sample sizes are unequal, which in an online experiment is the ordinary case rather than an edge one.

Frequently asked questions

Should I use a t-test or a z-test?
Use a t-test for comparing means and a z-test for comparing proportions. The textbook distinction — that a z-test applies when the population standard deviation is known — almost never decides anything in practice, because it is essentially never known. At the sample sizes online experiments run at the two give nearly identical answers for means anyway, so the useful rule is the one about what you are measuring: converted or not is a proportion, revenue per user is a mean.
Can I run a t-test when the two groups are different sizes?
Yes, and Welch's version handles it properly. Unequal group sizes cost you some statistical power compared with an even split, because the precision of the comparison is limited by the smaller arm, but they do not invalidate anything. The one thing to avoid is combining unequal sizes with the pooled Student's test when the variances also differ — that specific combination is where the reported p-value stops being trustworthy.
Can I use a t-test on a conversion rate?
You can, and it will usually give an answer close to the right one, because a conversion rate is a mean of zeros and ones. But the purpose-built tests are better: a two-proportion z-test or a chi-square test use the fact that the variance of a proportion is determined by the proportion itself, which a t-test has to estimate. The gap matters most when conversion rates are very low or the sample is small, which is exactly when you are least able to afford a loss of precision.
My t-test is significant but the difference is tiny. What went wrong?
Nothing went wrong — that is the test working as designed. A t-test measures how confident you can be that a difference is not zero, and with a large enough sample it detects differences far too small to act on. The fix is to decide the smallest difference worth shipping before the test starts and read the confidence interval against it. If the whole interval sits below that threshold, the result is a confident finding of no practical effect.

Related terms

  • Degrees of freedom

    The count of what is still free to move — and the number that decides how demanding your significance threshold is.

  • One-tailed vs two-tailed test

    The choice that halves your p-value and costs you the ability to see damage — and why it must be made before the data arrives.

  • T-distribution

    The bell curve's cautious cousin — and the reason a small sample needs a bigger result to clear the same bar.

  • Variance

    Spread in squared units — awkward to read, and the quantity every sample-size formula is built on.

  • Z-test

    The test behind every conversion-rate readout — and the one condition that decides whether it is safe to use.

  • ANOVA

    One test for three or more variants — and the reason it deliberately refuses to say which one won.

  • Equivalence test

    The only test that can conclude "these are the same" — done as two one-sided tests against a band you set first.

  • Interaction effect

    When two changes stop being independent — the reason concurrent tests can both read as wins and lose money together.

Calculate it

  • Two-sample t-test

    Compare the average of two independent groups — plan the sample size, then test the result.

  • Paired t-test

    Before-and-after or matched pairs — size the study on the difference SD, then test it.

Knowing the term is the easy part

Applying it to a live measurement problem is the part that goes wrong. If you are designing an experiment, reading a result you do not trust, or trying to work out what your marketing actually caused, that is the work we do.