T-Test Calculator

Perform hypothesis testing using the Student's t-distribution.

One-Sample

Two-Sample

Paired

Result
—
Enter data and calculate
t-Statistic
—
Degrees of Freedom
—
p-Value
—
Critical Value
—
Sample Mean
—
Sample SD
—
95% CI
—
Decision
—

Quick Examples

T-Distribution & T-Test

The t-test determines if there's a significant difference between means. It's used when the population standard deviation is unknown or sample sizes are small. Every t-test follows the same five-step logic: state the null and alternative hypotheses, compute the t-statistic from your data, find the degrees of freedom, look up the p-value (or compare against a critical value), and make a decision at your chosen significance level α.

One-Sample T-Test Formula

t = (x̄ - μ₀) / (s / √n)

Types of T-Tests

TypeUse Case
One-SampleCompare sample mean to known value
Two-SampleCompare means of two independent groups
PairedCompare before/after or matched pairs

Interpreting Results

  • p < α: Reject null hypothesis (significant difference)
  • p ≥ α: Fail to reject null (no significant difference)

T-Distribution Properties

  • Bell-shaped, symmetric around 0
  • Heavier tails than normal distribution
  • Approaches normal as df increases

The Five Numbers Every T-Test Reports

A t-test result is never a single number. To understand and report a test properly, you need all five of these statistics:

  • T-statistic: the signal-to-noise ratio — how many standard errors the sample mean sits from the null hypothesis value. Larger |t| means stronger evidence against the null hypothesis. A positive t means the sample mean is above the null value; negative means below.
  • Degrees of freedom (df): based on your sample size(s); it determines which t-distribution curve judges your result. Smaller df means a wider, flatter curve, which makes significance harder to reach.
  • P-value: the probability of seeing a t-statistic as extreme as yours if the null hypothesis were true. It is not the probability that the null hypothesis is true. If p is below your significance level α (usually 0.05), the result is statistically significant.
  • Confidence interval (CI): a range of plausible values for the true mean or mean difference. If a 95% CI for a difference excludes zero, the difference is significant at α = 0.05.
  • Effect size (Cohen's d): the practical size of the difference in standard deviation units. Significance tells you whether an effect exists; effect size tells you whether it matters. Conventional bands: below 0.2 negligible, 0.2–0.5 small, 0.5–0.8 medium, above 0.8 large.

How to Calculate a T-Test by Hand

Working one t-test by hand shows exactly what the calculator above does behind the scenes. Here is a full one-sample example.

Worked Example: Exam Scores

A professor claims the class average on a statistics exam should be 75 points (μ₀ = 75). A sample of 30 students has a mean of x̄ = 78.5 and a standard deviation of s = 9.2. Test at α = 0.05 whether the class mean differs from the claimed value (two-tailed).

Step 1 — State the hypotheses. H₀: μ = 75 (the class mean equals the claimed value). H₁: μ ≠ 75 (the class mean differs).

Step 2 — Calculate the standard error.

SE = s / √n = 9.2 / √30 = 9.2 / 5.477 = 1.680

Step 3 — Calculate the t-statistic.

t = (x̄ − μ₀) / SE = (78.5 − 75) / 1.680 = 3.5 / 1.680 = 2.084

Step 4 — Find the degrees of freedom. df = n − 1 = 30 − 1 = 29.

Step 5 — Find the p-value. For t = 2.084 with df = 29 (two-tailed), the critical value at α = 0.05 is t* = 2.045. Since |2.084| > 2.045, the result is significant; the exact p-value is approximately 0.046.

Step 6 — Decide and interpret. Since p = 0.046 < 0.05, reject H₀. There is enough evidence that the class mean differs from 75. The 95% CI for the true mean is 78.5 ± 2.045 × 1.680 = [75.07, 81.94]. Effect size: d = 3.5 / 9.2 = 0.38 (small-to-medium).

Formulas for All Four T-Test Types

Test TypeT-StatisticDegrees of Freedom
One-samplet = (x̄ − μ₀) / (s / √n)df = n − 1
Two-sample (pooled, equal variances)t = (x̄₁ − x̄₂) / (sₚ√(1/n₁ + 1/n₂))df = n₁ + n₂ − 2
Welch's (unequal variances)t = (x̄₁ − x̄₂) / √(s₁²/n₁ + s₂²/n₂)Welch–Satterthwaite (non-integer)
Pairedt = d̄ / (s_d / √n)df = n − 1 (n = pairs)

The pooled standard deviation for the two-sample test is sₚ = √[((n₁−1)s₁² + (n₂−1)s₂²) / (n₁+n₂−2)]. Welch's t-test skips the equal-variance assumption entirely and is the safer default when group spreads differ.

Assumptions of the T-Test

  • Normality: the data (or the difference scores for a paired test) should be approximately normally distributed. This matters most for small samples; with about 30 or more observations per group, the central limit theorem makes the test robust to skew.
  • Independence: each observation must be independent of the others. Repeated measurements on the same subject belong in a paired test, not an independent one.
  • Homogeneity of variance: the classic two-sample t-test assumes equal population variances. If the larger group's standard deviation is more than about twice the smaller's, use Welch's t-test instead.
  • Interval or ratio scale: the outcome must be continuous numeric data (test scores, weights, times). For ranked or ordinal data, use a nonparametric alternative such as the Mann–Whitney U test.

T-Test vs Z-Test: When to Use Which

FeatureT-TestZ-Test
Population SD (σ) known?No — uses the sample SDYes
Sample sizeAny size; essential when n < 30Large (roughly n > 30)
Distribution usedt-distribution (heavier tails)Standard normal
Critical value at α = 0.05 (two-tailed)~2.045 (df = 29) → 1.96 as df → ∞1.96 (fixed)

Paired vs Independent T-Test

FeaturePairedIndependent
SubjectsSame subjects at two time pointsTwo separate, unrelated groups
Unit of analysisDifference score per subject (d = x₁ − x₂)Each group's sample mean
Controls individual variation?Yes — removes between-subject noiseNo
Degrees of freedomn − 1 (n = pairs)n₁ + n₂ − 2
Typical useBefore/after studies, matched case-controlTwo-group trials, A/B tests

How to Report Your Result

A complete t-test report fits in one line: the test statistic with degrees of freedom, the p-value, and the effect size. For the exam-score example above:

t(29) = 2.084, p = 0.046, d = 0.38

Always report the exact p-value rather than "p < 0.05", include the mean difference with its confidence interval, and pair every significance claim with an effect size so readers can judge practical importance.

Common Mistakes

  • Saying the p-value is the probability the null is true: a p-value of 0.04 does not mean there is a 4% chance the null is true. It means: if the null were true, 4% of studies would produce a t-statistic this large.
  • "Accepting" the null hypothesis: a non-significant result only means the data are insufficient to reject it — it never proves the groups are equal. A larger sample might reach significance.
  • Choosing one-tailed after seeing the data: picking a one-tailed test because the two-tailed p was 0.08 invalidates the test. Decide the tail before collecting data.
  • Running an independent test on paired data: before/after measurements on the same subjects must use the paired test, which analyzes the differences, not the two group means separately.
  • Ignoring effect size: with large samples, even trivial differences become "significant". A p of 0.0001 with d = 0.05 is a real but practically meaningless effect.

Frequently Asked Questions

When should I use t-test vs z-test?
Use t-test when population standard deviation is unknown or sample size is small (n < 30). Use z-test when population SD is known and sample size is large.
What is the difference between one-tailed and two-tailed tests?
Two-tailed tests check for any difference. One-tailed tests check for difference in a specific direction (greater than or less than).