t-Test Calculator

Paste your data — or enter summary statistics — choose the test, and get the t statistic, degrees of freedom, and exact one- and two-tailed p-values, with every formula on the page.

Result

t statistic
degrees of freedom
p (two-tailed)
p (one-tailed)

How this calculator works

Pick the flavor of test, paste your numbers (any separator works), and the calculator computes the sample statistics, the t statistic, the degrees of freedom, and exact p-values — no table lookup, no rounding to "between 0.05 and 0.10". The summary line under the results shows the means and standard deviations it computed, so you can check them against your own and catch a data-entry slip before trusting the p.

The two-sample mode uses Welch's unequal-variance form with Satterthwaite degrees of freedom — the modern default — and the paired mode reduces the pairs to differences and runs a one-sample test on them, which is exactly what "paired t-test" means. Both one- and two-tailed p-values are reported; the FAQ covers when each is honest to use.

The formula

One-sample:  t = (x̄ − μ₀) / (s ÷ √n)          df = n − 1
Welch:       t = (x̄₁ − x̄₂) / √(s₁²/n₁ + s₂²/n₂)
             df = (s₁²/n₁ + s₂²/n₂)² / [ (s₁²/n₁)²/(n₁−1) + (s₂²/n₂)²/(n₂−1) ]
Paired:      t = d̄ / (s_d ÷ √n)               df = n − 1

p (two-tailed) = I_x(df/2, ½)  with  x = df/(df + t²)

Test statistics follow the NIST/SEMATECH e-Handbook of Statistical Methods (§1.3.5.2–1.3.5.3, itl.nist.gov); the two-sample degrees of freedom is the Welch–Satterthwaite approximation. The p-value uses the exact incomplete-beta identity for the t distribution, computed with the continued-fraction algorithm from Numerical Recipes§6.4 and verified against published critical values (t = 2.228 at df = 10 returns p = 0.0500).

Worked example

A label claims 2.0 g of protein per serving. Eight servings measure 2.1, 1.9, 2.4, 2.3, 2.2, 2.0, 2.5, 1.8 (the calculator's default):

  1. n = 8, x̄ = 2.15, s = 0.2449
  2. Standard error: 0.2449 ÷ √8 = 0.0866
  3. t = (2.15 − 2.0) ÷ 0.0866 = 1.732, df = 7
  4. p (two-tailed) = 0.1269

The servings average 7.5% over the label, but with only eight measurements that difference doesn't clear the conventional bar — p ≈ 0.13 means data like this would arise by chance about one time in eight even if the true mean were exactly 2.0. More samples, not more certainty, is the honest next step.

Assumptions & tips

  • Decide the tail before you look. Choosing one-tailed after seeing the data halves your p-value dishonestly. Pre-register the question, even if only with yourself.
  • Plot first, test second. A histogram or dot plot catches outliers, skew, and typos that no p-value will confess to. The t-test is robust, not immune.
  • Pair when the design allows. Before/after on the same subjects, matched samples, split plots — the paired test removes between-subject noise and often finds effects the two-sample test misses on identical data.
  • Report the estimate, not just the verdict."Mean difference 4.9 points (p = 0.002)" informs; "significant (p < 0.05)" hides everything a reader needs.
  • Multiple tests inflate false positives. Run twenty t-tests at α = 0.05 and one "significant" result is expected by chance alone. If you tested many things, say so, and consider a correction.

Frequently asked questions

Which t-test do I need?

One-sample compares one group's mean against a known or claimed value — label claims, spec targets. Two-sample compares the means of two independent groups — treatment versus control. Paired compares two measurements on the same subjects — before versus after — by testing whether the differences average zero. Choosing paired when the data really are paired is a big power win, because it removes subject-to-subject variation from the noise.

What does the p-value actually mean?

The probability of seeing a test statistic at least as extreme as yours if the null hypothesis were true. A p of 0.03 says: if the true means were equal, only 3 percent of repeated experiments would produce a difference this large by chance. It is not the probability the null is true, and it says nothing about how big or important the difference is — report the means and a sense of effect size alongside it.

One-tailed or two-tailed?

Two-tailed asks "is it different?"; one-tailed asks "is it bigger?" (or smaller), decided before seeing data. Two-tailed is the safe default and what most journals expect. Using a one-tailed p because it crosses 0.05 when the two-tailed doesn't is the classic way to fool yourself — this calculator shows both so the temptation is at least visible.

Why does the two-sample test use Welch's version?

The classic pooled t-test assumes both groups have equal variance; Welch's version does not, at the cost of a slightly odd degrees-of-freedom number (the Welch–Satterthwaite approximation, which is why df can be fractional). When variances happen to be equal, Welch gives nearly identical answers; when they are not, pooled can be badly wrong. Statisticians increasingly recommend Welch as the default, and this calculator follows that advice.

What assumptions am I making?

Independent observations within (and between) groups, and data that are roughly normal or samples large enough (a few dozen) for the Central Limit Theorem to smooth things over. Heavily skewed small samples and outliers can mislead the t-test; a quick look at your data before testing is worth more than any p-value after.

Sources

  1. NIST/SEMATECH e-Handbook of Statistical Methods (NIST Handbook 151), §7.2.2 — Are the data consistent with the assumed process mean? — National Institute of Standards and Technology, 2020. itl.nist.govThe one-sample test statistic t = (x̄ − μ₀) ÷ (s ÷ √n) with n − 1 degrees of freedom, as computed in one-sample mode.
  2. NIST/SEMATECH e-Handbook of Statistical Methods (NIST Handbook 151), §1.3.5.3 — Two-Sample t-Test for Equal Means — National Institute of Standards and Technology, 2020. itl.nist.govThe unequal-variance statistic and the Welch–Satterthwaite degrees-of-freedom formula used in two-sample mode, which is why the df reported there can be fractional.
  3. STAT 500: Applied Statistics — Lesson 7, Comparing Two Population Parameters — Penn State Department of Statistics. online.stat.psu.eduInference for paired means — reducing the pairs to differences and testing whether their mean is zero — which is what paired mode does, and the independent-versus-paired distinction the first FAQ draws.
  4. NIST Digital Library of Mathematical Functions — §8.17 Incomplete Beta Functions — National Institute of Standards and Technology (DLMF release of 2026-06-15). dlmf.nist.govDefines the regularized incomplete beta function I_x(a, b) and its continued fraction — the identity p = I_x(df/2, ½) that turns t and df into the exact p-values shown, rather than a table lookup.
  5. The Probable Error of a Mean — "Student" (W. S. Gosset), Biometrika, volume 6, number 1, pages 1–25, 1908. The original derivation of the t distribution whose tail areas this calculator evaluates. Cited bibliographically: no stable free full text was found to link.
  6. The Generalization of 'Student's' Problem when Several Different Population Variances are Involved — B. L. Welch, Biometrika, volume 34, issue 1–2, pages 28–35, 1947. Origin of the unequal-variance t-test that two-sample mode runs by default. Cited bibliographically: no stable free full text was found to link.
  7. Numerical Recipes: The Art of Scientific Computing, 3rd edition — W. H. Press, S. A. Teukolsky, W. T. Vetterling and B. P. Flannery, Cambridge University Press, 2007. The continued-fraction algorithm for the incomplete beta function used by this page's p-value routine, named in the formula section above.