T-Test Calculator

Compare an estimated mean or difference with a value you specify, and see the uncertainty around it. Enter individual observations or sample summaries, choose the study design and alternative, and connect the t statistic and p-value to the data, confidence interval and reference distribution.

Statistics workspace

Compare means with their uncertainty

Welch compares independent groups without assuming their population variances are equal. Raw and summary entries are kept separately.

Try a comparison

Enter your observations

Group A
Group B
Paste observations

Separate values with commas, semicolons, tabs, spaces or newlines. No headers, empty cells or internal blank rows. Import replaces the selected data only after the entire paste is valid. Maximum 500 observations per group.

Values use a common measurement unit. Raw samples allow 2–500 values; summaries allow n from 2 to 1,000,000. Use sample SD, not standard error. Missing or invalid entries are not removed or replaced.

Specify the comparison

Zero tests no mean difference. A nonzero value tests a specified difference.

The alternative also determines whether the confidence interval has two finite ends or one infinite end.

0.05 gives a 95% matching confidence interval or one-sided bound. Allowed α: 0.0001–0.25.

Choose the comparison and threshold for the question you intended to ask. Changing the direction or threshold after seeing the data changes the analysis; this calculator does not certify a prespecified test.

Mean difference · A − B: -1. P-value 0.287864. At or above selected significance level 0.05.

Mean difference · A − B

-1

Null: 0. Estimate minus null: -1.

95% confidence interval

-3.26696 to 1.26696

For the same mean or difference and alternative as the test. Limits are approximate.

Approximate p-value

0.287864

At or above the selected α = 0.05. This alone does not establish a meaningful effect or prove equality.

A p-value describes how unusual a statistic this extreme would be under the null model and its assumptions. It is not the probability that the null is true, not an effect size, and not evidence of causation. A large p-value does not prove equality or practical equivalence.

Keep these limits in view

  • For small samples, strong skew or influential outliers can undermine the Student-t reference model; a small-sample count alone does not validate normality.

The observations behind the means

Each circle is one entered observation. Vertical staggering separates overlapping points; it does not encode another variable.

Entered sample observationsHorizontal coordinates are offsets from 2. Group A: 3 observations, mean offset 0, SD 1. Group B: 3 observations, mean offset 1, SD 1. Full values are in Sample summaries and results.-1.24-0.370.51.372.24AGroup A, row 1, offset -1Group A, row 2, offset 0Group A, row 3, offset 1BGroup B, row 1, offset 0Group B, row 2, offset 1Group B, row 3, offset 2Value offset

Read the horizontal scale as 2 + offset. Means are outlined diamonds. Close observations may overlap at this scale; the ledger retains each value.

Group AGroup B

Estimate and confidence interval

95% two-sided interval for the population mean difference A − B. The dashed marker is the entered null value.

Estimate, confidence limits and null valueEstimate -1; interval -3.26696 to 1.26696. Null value 0 is shown as a dashed line. All coordinates are offsets from the estimate.-2.2702.27Offset from estimate

Origin: -1. Interval limits use an approximate Student-t critical value.

Where the t statistic sits

This is the reference Student-t density under the null, not a fitted curve through your observations. Green shading marks the visible part of the p-value tails; dashed blue markers show the selected threshold.

Reference Student-t distribution and selected tailsReference density with 4 degrees of freedom. Observed t -1.22474, inside the displayed range -4 to 4. P-value 0.287864. The bounded drawing omits tail probability 0.0161301 outside this window.t-404t statistic (dimensionless)

Observed t: -1.22474. Degrees of freedom: 4.

Threshold markers: -2.77645 and 2.77645.

This finite window excludes probability 0.0161301 across its two outer tails. The visible shaded area is not the complete p-value; calculation uses the full distribution.

Sample summaries and results

Descriptive summaries of the entered samples
SamplenMeanSample SDSample variance
Group A32≈ 11
Group B33≈ 11

SD uses the sample denominator n − 1. Paired inference uses the SD of the A − B differences. Approximate distribution values are marked with ≈; full values and exact fractions are available below.

Standard error
≈ 0.816497
t statistic
≈ -1.22474
Degrees of freedom
≈ 4
Significance threshold
α = 0.05
Full calculation values
Estimate, exact fraction
-1
Null, exact fraction
0
Estimate minus null, exact fraction
-1
Standard error squared, exact fraction
2/3
t statistic, approximate
-1.224744871391589
Degrees of freedom, exact
4
P-value, approximate
0.287864
Natural log of p
-1.2452666645785342
Complement 1 − p
0.712136
Natural log of 1 − p
-0.3394865637612893
Interval lower endpoint
-3.266957935527531
Interval upper endpoint
1.266957935527531
Finite bound distance from estimate
2.266957935527531
Student-t critical value
2.7764451051978085

Infinite interval ends are mathematical bounds, not numerical failures. Exact fractions describe arithmetic from the supplied decimals; they do not imply that the measurements themselves are exact.

Entered observations
Original observation order and calculated differences
RowAB
112
223
334

An em dash means the independent group has no observation at that row index. It is not treated as a missing value or a new pair.

Exports include entered values, design, alternative, threshold, summaries, inference and calculation details. Raw paired observations retain their original row order.

View CSV text
Method, assumptions and sources
  • Observations are independent within and, where applicable, between groups.
  • Student-t inference assumes an appropriate normal-population model, or an adequate sampling approximation for the mean; this calculator does not test that assumption.
  • Standard deviations are sample standard deviations (n − 1 denominator), not population SDs or standard errors.
  • A p value is not the probability that the null hypothesis is true; failing to reject does not establish equivalence or a causal effect.
  • Intervals and p values condition on the chosen design, alternative, null value and alpha; no multiple-testing adjustment is applied.

Raw decimal observations and centered moments are retained as exact fractions. Standard deviations, distribution probabilities, critical values and interval widths use approximate numerical calculations. Full fraction and decimal values remain in the ledger and CSV. Very small tail probabilities are shown as bounds with logarithms, not a misleading exact zero.

Estimate the population mean or mean difference

estimate = mean(A) − mean(B)

-1

Compare the estimate with the stated null

contrast = estimate − null value

-1

Standardize the contrast

t = contrast / SE; sample variances use n − 1

-1.224744871391589; df = 4

Match the interval to the alternative

Two-sided: estimate ± t(1 − α/2, df) × SE; greater: [estimate − t(1 − α, df) × SE, +∞); less: (−∞, estimate + t(1 − α, df) × SE]

Alternative: two-sided; alpha: 0.05

Methods: NIST t-tests, NIST two-sample assumptions, and R t-test alternatives and matching intervals. Interpretation: ASA statement on p-values.

This workspace does not validate random sampling, independence, normality, equal variances, measurement quality or research design. It performs no automatic outlier removal, multiple-testing correction, equivalence test or causal analysis.

How to use this calculator

  1. Choose one sample, matched pairs, independent Welch or the equal-variance pooled design. Welch does not require equal population variances; paired observations must represent actual matches.
  2. Enter individual observations or switch to sample summaries. For a paired summary, enter the number of pairs, mean A − B difference and sample SD of those differences. Two separate group SDs cannot replace that information.
  3. Specify the null mean or null A − B difference, alternative and significance level α. Choose a directional alternative for the question you planned to investigate; changing it after looking at the data changes the analysis.
  4. Read the estimate and matching confidence interval or one-sided bound beside the p-value. Inspect raw observations or summary markers, the interval diagram and the Student-t tail view. Values outside the drawn reference range remain identified numerically.
  5. Review sample summaries, assumptions and calculation steps. Download the complete CSV or open its selectable text. Correct any incomplete input before using results or export.

The Formula

The mathematical logic powering this calculation is:

For observations x₁,…,xₙ, x̄ = Σxᵢ/n and sample variance s² = Σ(xᵢ − x̄)²/(n − 1).
One sample: estimate = x̄, SE² = s²/n, df = n − 1.
Paired: first form dᵢ = Aᵢ − Bᵢ, then use the one-sample formulas on the differences.
Welch: estimate = x̄A − x̄B, SE² = sA²/nA + sB²/nB, df = (sA²/nA + sB²/nB)² / [(sA²/nA)²/(nA − 1) + (sB²/nB)²/(nB − 1)].
Pooled: sp² = [(nA − 1)sA² + (nB − 1)sB²]/(nA + nB − 2), SE² = sp²(1/nA + 1/nB), df = nA + nB − 2.
For nonzero SE, t = (estimate − null value)/SE. With F the Student-t CDF, p = 2 min(F(t), 1 − F(t)) for a two-sided alternative, F(t) for less, and 1 − F(t) for greater. The implementation evaluates small tails directly.
A two-sided (1 − α) interval is estimate ± t(1 − α/2, df)SE. The corresponding greater alternative has lower bound estimate − t(1 − α, df)SE and no finite upper bound; less has no finite lower bound and upper bound estimate + t(1 − α, df)SE.

Worked Example

If you input:

  • Study design: Independent groups — Welch
  • Input format: Individual observations
  • Group A observations: 1, 2, 3
  • Group B observations: 2, 3, 4
  • Null mean or A − B difference: 0
  • Alternative: Different from null
  • Significance level α: 0.05

Result:

For A = [1,2,3] and B = [2,3,4], the means are 2 and 3 and both sample variances are 1. The estimated A − B difference is −1, SE ≈ 0.8164965809, t ≈ −1.2247448714 and Welch df = 4. The two-sided p-value is approximately 0.2878641347. The 95% interval for the difference is approximately [−3.2669579355, 1.2669579355]. This p-value is not below α = 0.05; it does not prove that the population means are equal.

Frequently Asked Questions

Which t-test should I choose?

Use one sample to compare a quantitative mean with a specified value. Use paired data for repeated measurements or genuinely matched observations, analyzing A minus B within each pair. Use Welch for two independent groups when equal variances are not assumed. Pooled mode adds an equal-population-variance assumption. The calculator does not choose the design from a variance test or from whichever result has the smaller p-value.

Can I use sample summaries instead of individual observations?

Yes. Enter each relevant sample size, mean and sample standard deviation. For matched pairs, supply the mean and sample standard deviation of the within-pair A − B differences and the number of complete pairs. Marginal group summaries omit the pairing covariance and cannot recover that SD. Summary mode shows summaries and inference; it does not reconstruct an observed distribution or identify individual outliers.

What do the p-value and significance comparison mean?

The p-value describes the selected test statistic's tail probability under the null reference model and its assumptions. It is not the probability that the null hypothesis is true, the probability of chance alone, or the size or practical importance of a difference. A p-value at or above α does not establish equality. Consider the estimated difference, interval, study design and consequences together; this tool does not perform an equivalence test or adjust multiple comparisons.

Why does changing the alternative change the interval?

The interval matches the selected alternative at confidence 1 − α. A two-sided test uses two finite bounds and α/2 in each reference tail. A greater-than alternative reports a finite lower bound with an unbounded upper end; a less-than alternative reports an unbounded lower end and a finite upper bound. These are intervals for the population mean or mean difference, not ranges for individual observations. Confidence describes the procedure's repeated-sampling coverage under its assumptions.

What assumptions does the calculator check?

It checks numeric inputs and relationships such as matching pair counts. It cannot establish random sampling, independent observations, appropriate matching or a valid study design. Small-sample t inference relies on a suitable normal-population model; for paired tests this concerns the differences. Welch uses an approximate reference degree of freedom for unequal variances, while pooled inference assumes a common population variance. Outliers, skew, dependence and selective analysis can undermine interpretation. No observations are automatically discarded.

What happens when the data are constant?

Valid descriptive summaries remain available. If the estimated standard error is exactly zero, the t statistic, p-value and t confidence interval are reported as undefined, rather than as infinite evidence or a zero-width certainty statement. An independent comparison with only one zero-variance group can still have a positive standard error; the model handles that separately and states its assumptions.

How are precision and very small probabilities handled?

Entered decimal observations, means and SDs are retained for rational arithmetic on centered moments, mean differences and variance terms before numerical conversion. Square roots, t distribution functions and interval widths are approximations. Small probabilities retain their natural logarithms, and near-one probabilities retain their complementary tail. Interval text and plot offsets preserve a narrow width around a large estimate. More digits do not improve measurement accuracy or establish the statistical assumptions.

Which inputs and imports are supported?

Raw mode accepts 2–500 complete observations per group or matched pairs. Summary sample sizes are integers from 2 to 1,000,000. Observation, mean, null and SD magnitudes may not exceed 10¹²; SDs must be nonnegative. Decimal/scientific inputs allow up to 24 significant digits and 24 effective fractional places, with at most 160 characters per value. α is from 0.0001 to 0.25 with at most 12 effective fractional places. Import accepts plain numeric data without headers, expressions or missing cells, and rejects the whole import if it is invalid. Numerical-limit failures are stated explicitly.

Similar Calculators