T-Test Calculator

Run a one-sample, paired, Welch or pooled t-test from raw data or mean, SD and n. Get t, degrees of freedom, the p-value, a confidence interval and Cohen's d.

The interactive tool loads here when JavaScript runs.

About this tool

What is the T-Test Calculator?

The T-Test Calculator compares means. Choose a one-sample test (is this mean different from a target value?), a paired test (did the same subjects change between two conditions?) or a two-sample test (do two independent groups differ?), then paste raw data or type the mean, standard deviation and sample size for each group. It returns the t statistic, the degrees of freedom, the p-value for a two-sided or one-sided alternative, the confidence interval for the mean or the difference, and Cohen's d as an effect size.

For two independent groups the default is Welch's t-test, which does not assume the groups have equal variances; tick one box for Student's pooled-variance test instead. A shaded t curve shows where your statistic falls and how much tail area makes up the p-value, and a "How this was calculated" panel lists the standard error, t, the Welch-Satterthwaite degrees of freedom and the interval step by step. The default data are the sleep measurements William Gosset analysed in his 1908 paper, so you can compare the result with the original.

  • One-sample, paired, Welch and Student pooled two-sample tests
  • Raw data or summary statistics (mean, SD, n) input
  • Two-sided and one-sided p-values with matching confidence intervals
  • Cohen's d, and Hedges' g for two groups
  • Shaded t distribution and step-by-step working
  • Matches R t.test and SciPy to 9+ significant figures; runs in your browser
Read the guide: How to Do a t-Test: One-Sample, Paired and Welch

How to use the T-Test Calculator

  1. Pick One-sample, Paired or Two-sample.
  2. Paste raw values, or for one-sample and two-sample tests switch to "Mean, SD, n" and type the summary statistics. For a paired test, the n-th value in column 2 must belong to the same subject as the n-th value in column 1.
  3. For two independent groups, leave "Assume equal variances" unticked for Welch's test or tick it for Student's pooled test.
  4. Set the hypothesised value (usually 0 for a difference), the significance level and the alternative: two-sided, or one-sided if the direction was fixed before you saw the data.
  5. Read t, df, the p-value, the confidence interval and Cohen's d, then copy the summary or share a link.

Worked examples

Student's sleep data, paired (the default)

Input

Drug 1: 0.7, -1.6, -0.2, -1.2, -0.1, 3.4, 3.7, 0.8, 0.0, 2.0; Drug 2: 1.9, 0.8, 1.1, 0.1, -0.1, 4.4, 5.5, 1.6, 4.6, 3.4

Output

Mean difference -1.58, t = -4.0621, df = 9, p = 0.002833, 95% CI -2.460 to -0.700

Every patient but one slept longer on drug 2, and pairing uses that consistency. The differences have SD 1.23, so SE = 1.23 / √10 = 0.389 and t = -1.58 / 0.389.

The same data as two independent groups

Input

Two-sample, Welch, same two columns

Output

t = -1.8608, df = 17.776, p = 0.07939, 95% CI -3.365 to 0.205

Ignoring the pairing adds the between-patient spread to the error term, and the difference is no longer significant at 5%. Choosing the right test matters more than any rounding.

Two classes from summary statistics

Input

Class A: mean 24.6, SD 4.2, n 18; Class B: mean 21.3, SD 5.1, n 20; Welch, two-sided

Output

t = 2.1852, df = 35.74, p = 0.0355, 95% CI 0.237 to 6.363, Cohen's d = 0.70

Class A scored 3.3 points higher. The interval excludes 0, matching p < 0.05, and d = 0.70 is a medium-to-large effect by Cohen's benchmarks. The pooled test gives t = 2.1627 with 36 df and p = 0.0373.

Background and insight

William Sealy Gosset worked as a chemist at the Guinness brewery in Dublin, where experiments used small batches. He showed that when the standard deviation is estimated from a small sample, the statistic (x̄ - μ) / (s / √n) follows a wider-tailed distribution than the normal, and published it in Biometrika in 1908 under the pen name "Student". Fisher later reshaped the result into the t distribution with n - 1 degrees of freedom used today. With 9 degrees of freedom the two-sided 5% critical value is 2.262 rather than the normal 1.960; by 30 degrees of freedom it is 2.042 and the difference keeps shrinking.

The pooled two-sample test assumes both groups share one variance. When they do not, and especially when the smaller group has the larger spread, its false-positive rate can be far from the stated 5%. Bernard Welch (1947) fixed this with a separate-variance standard error and fractional degrees of freedom from the Welch-Satterthwaite formula. Because Welch's test loses almost no power when variances are equal, R's t.test uses it by default and many statisticians recommend it as the standard choice.

A paired test is a one-sample test on the differences. Pairing removes the large person-to-person variation, which is why the same numbers can give very different answers. Run on the sleep data (two drugs given to the same ten patients), the paired test gives t = -4.06 and p = 0.0028, while treating the columns as independent groups gives p = 0.079. The results here match R's t.test and SciPy's ttest_rel and ttest_ind to 9 or more significant figures in the test suite.

Common use cases

  • A/B tests on averages

    Compare average order value, session length or task time between two variants with Welch's test.

  • Before and after studies

    Use the paired test for the same people measured twice, such as blood pressure before and after a treatment.

  • Quality control

    Test whether a batch mean differs from the specification with a one-sample test against the target value.

  • Coursework and papers

    Report t, df, p, the confidence interval and an effect size in the format journals ask for, and check software output.

Tips and limitations

  • Decide on one-sided or two-sided before looking at the data. Switching to one-sided after seeing the direction halves the p-value and is not legitimate.
  • Paired data must be analysed as paired. Running an independent test on before/after measurements usually throws away most of the power.
  • The t-test assumes the means are roughly normally distributed. With 30 or more per group this is usually fine; with small, skewed samples consider a Wilcoxon or Mann-Whitney test.
  • A non-significant result is not evidence of no difference. Look at the confidence interval: a wide interval that includes both 0 and large effects means the study was too small to tell.
  • Enter the sample standard deviation (the n - 1 version). If you only have a standard error, multiply it by √n to get the SD.
  • Cohen's benchmarks of 0.2, 0.5 and 0.8 for small, medium and large are rough conventions; what counts as important depends on the field.

Frequently asked questions

Which t-test should I use?

Use a one-sample test to compare one mean with a fixed value, a paired test when each value in one column belongs to the same subject as a value in the other (before and after, left and right), and a two-sample test for two separate groups of subjects. For two groups, Welch's version is the safe default.

What is the difference between Welch's t-test and Student's t-test?

Student's two-sample test pools the two variances and assumes they are equal. Welch's test keeps them separate and adjusts the degrees of freedom. When variances are equal the two give nearly the same answer; when they differ, Welch's test keeps the error rate where it should be and Student's does not.

How do I calculate a t-test by hand?

Compute the standard error (s / √n for one sample or paired differences, √(s₁²/n₁ + s₂²/n₂) for Welch), divide the difference between the estimate and the hypothesised value by it to get t, find the degrees of freedom, and look up the tail area of the t distribution. The calculator shows each of these numbers.

What does the p-value of a t-test tell me?

It is the probability of a t statistic at least as extreme as yours if the true mean difference were the hypothesised value. A small p-value means the data would be unusual under that assumption. It is not the probability that the null hypothesis is true.

Can I run a t-test with only the mean and standard deviation?

Yes, for one-sample and two-sample tests. Switch the data source to "Mean, SD, n". A paired test needs the differences, so it needs the raw pairs or the mean and SD of the differences, which you can enter as a one-sample test against 0.

How large does my sample need to be for a t-test?

The test works for any n of 2 or more if the data are close to normal. With skewed data, the central limit theorem usually makes the mean close enough to normal by about 30 per group. Power is a separate question: detecting a small effect can need hundreds per group.

What is Cohen's d?

It is the difference in means divided by a standard deviation (the pooled SD for two groups, the SD of the differences for a paired test). It describes the size of an effect independently of sample size. Hedges' g applies a small correction for small samples.

Is there an in-depth guide to the T-Test Calculator?

Yes. “How to Do a t-Test: One-Sample, Paired and Welch” covers the background, how it works, common pitfalls and worked examples. Read the full guide.

People also search for

  • paired t test calculator with steps
  • welch t test calculator unequal variances
  • two sample t test from mean and standard deviation
  • one sample t test p value calculator
  • independent samples t test online
  • when to use paired vs unpaired t test
  • cohens d from t test
  • welch satterthwaite degrees of freedom