acalculator

What does my t-test show?

Enter your means, standard deviations, and sample sizes to run a t-test and see the t statistic, p-value, and decision on the t curve.

Your numbers

Test
Alternative hypothesis
t statistic
1.832151

t = 1.832151 with 62.95882 degrees of freedom and a p-value of 0.071659. Do not reject the null hypothesis at α = 0.05.

Degrees of freedom
62.95882
P-value
0.071659
Critical value
1.998366
Decision
Do not reject the null hypothesis
Estimate
5
Standard error
2.729033

t statistic: 1.832151. t = 1.832151 with 62.95882 degrees of freedom and a p-value of 0.071659. Do not reject the null hypothesis at α = 0.05.

Where does your t statistic fall?

How to calculate

Runs a one-sample, two-sample (Welch or pooled), or paired t-test from means, standard deviations, and sample sizes, with the t statistic, degrees of freedom, p-value, and decision.

Example with the default inputs (Test Two-sample, Mean (x̄₁) 75, Standard deviation (s₁) 10, Sample size (n₁) 30, Mean (x̄₂) 70, Standard deviation (s₂) 12, Sample size (n₂) 35, Variances Unequal (Welch), Hypothesized value (μ₀) 0, Alternative hypothesis Two-tailed (≠), Significance level (α) 0.05): t = 1.832151 with 62.95882 degrees of freedom and a p-value of 0.071659. Do not reject the null hypothesis at α = 0.05.

Method: t = (estimate − μ₀) ÷ SE. One-sample and paired: SE = s ÷ √n, df = n − 1. Welch: SE = √(s₁²/n₁ + s₂²/n₂), df = SE⁴ ÷ ((s₁²/n₁)²/(n₁ − 1) + (s₂²/n₂)²/(n₂ − 1)). Pooled: sp² = ((n₁ − 1)s₁² + (n₂ − 1)s₂²) ÷ (n₁ + n₂ − 2), SE = sp √(1/n₁ + 1/n₂), df = n₁ + n₂ − 2.

  • The observations are independent, and each mean is roughly normal (the data are close to normal, or the samples are large).
  • Standard deviations are sample standard deviations (divided by n − 1).
  • Welch’s degrees of freedom are fractional; the t distribution is evaluated at that fractional value.

Machine-readable copies: Markdown, JSON.

Worked examples

Each example is checked against the calculator on every build.

  1. Test Two-sample, Mean (x̄₁) 75, Standard deviation (s₁) 10, Sample size (n₁) 30, Mean (x̄₂) 70, Standard deviation (s₂) 12, Sample size (n₂) 35, Variances Unequal (Welch), Hypothesized value (μ₀) 0, Alternative hypothesis Two-tailed (≠), Significance level (α) 0.05 gives t statistic 1.832151, Degrees of freedom 62.95882, P-value 0.071659, Decision Do not reject the null hypothesis.Source: NIST/SEMATECH e-Handbook of Statistical Methods, §1.3.5.3 Two-Sample t-Test for Equal Means. https://www.itl.nist.gov/div898/handbook/eda/section3/eda353.htm
  2. Test Two-sample, Mean (x̄₁) 20.14458, Standard deviation (s₁) 6.4147, Sample size (n₁) 249, Mean (x̄₂) 30.48101, Standard deviation (s₂) 6.10771, Sample size (n₂) 79, Variances Equal (pooled), Hypothesized value (μ₀) 0, Alternative hypothesis Two-tailed (≠), Significance level (α) 0.05 gives t statistic -12.620585, Degrees of freedom 326, Pooled standard deviation 6.342601, Critical value 1.967268.Source: NIST/SEMATECH e-Handbook of Statistical Methods, §1.3.5.3 Two-Sample t-Test for Equal Means. https://www.itl.nist.gov/div898/handbook/eda/section3/eda353.htm (T = −12.62059, sp = 6.34260, ν = 326, critical value 1.9673)
  3. Test One-sample, Mean (x̄₁) 9.26146, Standard deviation (s₁) 0.022789, Sample size (n₁) 195, Hypothesized value (μ₀) 5, Alternative hypothesis Two-tailed (≠), Significance level (α) 0.05 gives t statistic 2,611.262029, Degrees of freedom 194, Critical value 1.972268, Decision Reject the null hypothesis.Source: NIST/SEMATECH e-Handbook of Statistical Methods, §1.3.5.2 Confidence Limits for the Mean (one-sample t-test). https://www.itl.nist.gov/div898/handbook/eda/section3/eda352.htm (T = 2611.284, ν = 194, critical value 1.9723)
  4. Test Paired, Mean of the differences (d̄) 1.5, SD of the differences (s(d)) 2, Number of pairs (n) 10, Hypothesized value (μ₀) 0, Alternative hypothesis Right-tailed (>), Significance level (α) 0.05 gives t statistic 2.371708, Degrees of freedom 9, P-value 0.020896, Critical value 1.833113.Source: OpenStax, Introductory Statistics 2e, §10.4 Matched or Paired Samples. https://openstax.org/books/introductory-statistics-2e/pages/10-4-matched-or-paired-samples
  5. Test One-sample, Mean (x̄₁) 12, Standard deviation (s₁) 3, Sample size (n₁) 9, Hypothesized value (μ₀) 10, Alternative hypothesis Left-tailed (<), Significance level (α) 0.05 gives t statistic 2, Degrees of freedom 8, P-value 0.959742, Critical value -1.859548.Source: NIST/SEMATECH e-Handbook of Statistical Methods, §1.3.5.2 Confidence Limits for the Mean (one-sample t-test). https://www.itl.nist.gov/div898/handbook/eda/section3/eda352.htm

How it works

All three tests compute t = (estimate − μ₀) ÷ SE and compare it with Student's t distribution with df degrees of freedom. μ₀ is the hypothesized value (default 0).

One-sample (mean x̄, standard deviation s, size n): estimate = x̄, SE = s ÷ √n, df = n − 1.

Paired (mean of the differences d̄, their standard deviation s(d), number of pairs n): estimate = d̄, SE = s(d) ÷ √n, df = n − 1.

Two-sample (x̄₁, s₁, n₁ and x̄₂, s₂, n₂): estimate = x̄₁ − x̄₂.

  • Welch (unequal variances): SE = √(s₁²/n₁ + s₂²/n₂), and df = (s₁²/n₁ + s₂²/n₂)² ÷ ((s₁²/n₁)² ÷ (n₁ − 1) + (s₂²/n₂)² ÷ (n₂ − 1)), usually a fraction.
  • Pooled (equal variances): sp = √(((n₁ − 1)s₁² + (n₂ − 1)s₂²) ÷ (n₁ + n₂ − 2)), SE = sp × √(1/n₁ + 1/n₂), df = n₁ + n₂ − 2. The pooled standard deviation sp is shown.

P-value, with T following Student's t with df degrees of freedom:

  • Left-tailed: P(T ≤ t).
  • Right-tailed: P(T ≥ t).
  • Two-tailed: 2 × the smaller of the two, at most 1.

Critical value at significance level α: the t with upper tail α ÷ 2 for a two-tailed test (reject when |t| is at least it), the t with upper tail α for a right-tailed test, and minus that for a left-tailed test (reject when t is at or below it).

Decision: "Reject the null hypothesis" when the p-value is α or less, otherwise "Do not reject the null hypothesis".

Rules

  • Standard deviations are above 0, sample sizes are whole numbers of at least 2, and means and μ₀ are from −10¹² to 10¹². α is from 0.0000000001 to 0.5.
  • Each tail of the t distribution is computed directly, not as 1 minus the other tail, so small p-values keep their precision. Below 1,000 degrees of freedom it comes from the incomplete beta function. From 1,000 degrees of freedom up, where that loses digits, it is the integral of the t density, f(s) = Γ((ν + 1)/2) ÷ (√(νπ) Γ(ν/2)) × (1 + s²/ν)^(−(ν + 1)/2), by 10-point Gauss–Legendre panels, and the critical value is found by Newton's method on that tail. P-values and critical values are good to at least 11 significant digits at any degrees of freedom (checked against mpmath up to 3.7 × 10⁹ degrees of freedom).
  • Results show up to 6 decimal places (6 significant digits below 0.0001), with halves rounded up.

Worked examples by hand

The default: two groups, Welch. x̄₁ = 75, s₁ = 10, n₁ = 30; x̄₂ = 70, s₂ = 12, n₂ = 35. s₁²/n₁ = 3.333333 and s₂²/n₂ = 4.114286, so SE = √7.447619 = 2.729033 and t = 5 ÷ 2.729033 = 1.832151. df = 7.447619² ÷ (3.333333² ÷ 29 + 4.114286² ÷ 34) = 62.95882. Two-tailed p-value = 0.071659, above 0.05: Do not reject the null hypothesis.

NIST car mileage, pooled. U.S. cars x̄₁ = 20.14458, s₁ = 6.41470, n₁ = 249; Japanese cars x̄₂ = 30.48101, s₂ = 6.10771, n₂ = 79. sp = √((248 × 6.41470² + 78 × 6.10771²) ÷ 326) = 6.342601; SE = 6.342601 × √(1/249 + 1/79) = 0.819; t = −10.33643 ÷ 0.819 = −12.620585, df = 326, critical value 1.967268. NIST reports T = −12.62059, sp = 6.34260, and 1.9673.

NIST one-sample test of μ = 5. x̄ = 9.261460, s = 0.022789, n = 195. SE = 0.022789 ÷ √195 = 0.001632; t = 4.26146 ÷ 0.001632 = 2611.262, df = 194, critical value 1.972268: Reject the null hypothesis. NIST reports T = 2611.284 from the unrounded data.

Paired, right-tailed. d̄ = 1.5, s(d) = 2, 10 pairs: SE = 2 ÷ √10 = 0.632456, t = 2.371708, df = 9. P(T ≥ 2.371708) = 0.020896; critical value 1.833113.

One-sample, left-tailed. x̄ = 12, s = 3, n = 9, μ₀ = 10: t = 2 ÷ 1 = 2, df = 8. P(T ≤ 2) = 0.959742, so the data give no evidence that the mean is below 10. Critical value −1.859548.

Other questions people ask

Which t-test should I use?

Use a one-sample test to compare one mean with a fixed value. Use a two-sample test to compare the means of two independent groups, such as two classes. Use a paired test when each subject is measured twice, such as before and after, and enter the mean and standard deviation of the differences.

Should I use Welch’s test or the pooled test?

Welch’s test is the safer default: it does not assume the two groups have the same variance, and it loses little when they do. The pooled (Student’s) test assumes equal variances; use it when you have good reason to, or when a course asks for it.

How is the t statistic calculated?

Divide the difference between the estimate and the hypothesized value by its standard error: t = (x̄ − μ₀) ÷ (s ÷ √n) for one sample. With x̄ = 12, μ₀ = 10, s = 3, and n = 9, t = 2 ÷ 1 = 2, with 8 degrees of freedom.

What does the p-value mean?

It is the chance, if the null hypothesis is true, of a t statistic at least as extreme as yours in the direction you are testing. When it is at or below your significance level α, the result is called significant and the null hypothesis is rejected.

What is the difference between a one-tailed and a two-tailed test?

A two-tailed test looks for a difference in either direction, so its p-value counts both tails. A one-tailed test looks in one direction only (less than, or greater than). Choose the direction before you look at the data.

Can I use raw data instead of summary statistics?

This calculator takes the mean, standard deviation, and size of each sample. To get them from a list of numbers, use the statistics calculator with "sample" chosen; for a paired test, first subtract each pair and enter the differences.

Why are Welch’s degrees of freedom not a whole number?

The Welch–Satterthwaite formula estimates the degrees of freedom from the two variances and sample sizes, so it usually gives a fraction, such as 62.96. The t distribution is defined for any positive degrees of freedom, and the calculator uses the exact fraction.