Independent Samples t-Test Calculator

StatisticsLast updated: August 22, 2026

The independent samples t-test examines whether the difference between the means of two separate groups is statistically significant. It is the standard test for comparing two sets of observations that were not measured on the same people — a treatment and a control group, female and male participants, or two different production lines.

This calculator produces both t values: the pooled (Student) t, which assumes equal variances, and the Welch-corrected t for the case where they are not equal. It decides which one should be reported by looking at the result of Levene's test, computes the confidence interval for the difference along with the Cohen d and Hedges g effect sizes, and compares the distributions of the groups in a box plot.

If you enter raw data, Levene's test and the box plot are produced as well.
Write the observations of one group on each line. You can add a label such as "Treatment:" at the start of a line.
A directional hypothesis should be chosen only if the direction of the difference can be justified in advance.
Sets the false positive risk. In the social sciences 5% is the common choice.
The probability that the interval covers the true parameter.

Independent Samples t-Test Formulas

Hypotheses:       H₀: μ₁ = μ₂   ·   H₁: μ₁ ≠ μ₂
Pooled variance:  sₚ² = [(n₁−1)s₁² + (n₂−1)s₂²] / (n₁ + n₂ − 2)
Pooled t:         t = (x̄₁ − x̄₂) / √(sₚ²·(1/n₁ + 1/n₂)),  df = n₁ + n₂ − 2
Welch t:          t = (x̄₁ − x̄₂) / √(s₁²/n₁ + s₂²/n₂)
Welch df:         df = (s₁²/n₁ + s₂²/n₂)² / [ (s₁²/n₁)²/(n₁−1) + (s₂²/n₂)²/(n₂−1) ]
Confidence int.:  (x̄₁ − x̄₂) ± t₍₁−α/₂; df₎ · SE
Cohen d:          d = (x̄₁ − x̄₂) / sₚ
Hedges g:         g = d · [1 − 3 / (4(n₁+n₂) − 9)]
Levene W:         W = [(N−k)/(k−1)] · Σnᵢ(z̄ᵢ − z̄)² / ΣΣ(zᵢⱼ − z̄ᵢ)²,  zᵢⱼ = |xᵢⱼ − medianᵢ|

Levene's test is applied in its median-centered (Brown–Forsythe) form, which is more reliable than the original mean-centered version on skewed distributions. If p ≥ 0.05, the variances are treated as homogeneous and the pooled t is reported.

How to Calculate

  1. In raw data mode, write the observations of the two groups on separate lines; if you like, add a label such as "Treatment:" at the start of a line.
  2. If you only have summary statistics, switch to the second mode and enter the mean, the standard deviation, and the sample size for both groups.
  3. Set the hypothesis direction, the significance level (α), and the confidence level.
  4. Look at the homogeneity of variance row first: if Levene's p ≥ 0.05, the pooled t should be reported; if p < 0.05, the Welch t should be.
  5. Read the t, df, and p values of the selected method together with the decision row; the shaded t curve shows where t falls relative to the rejection region.
  6. Add the confidence interval for the difference and the Cohen d and Hedges g values to your report; use the box plot to compare the spread and the outliers of the groups.

Worked Examples

Treatment and control group (raw data)

The treatment group has a mean of 83.90 (s = 5.11) and the control group a mean of 72.50 (s = 3.03). Levene's test gives W = 2.549; p = 0.128, so the variances are treated as homogeneous and the pooled t is reported: t = 6.070; df = 18; p < 0.001. The mean difference is 11.40 units with a 95% confidence interval of 7.45 to 15.35, and Cohen d = 2.715 with Hedges g = 2.600 indicates a very large effect.

t statistic (pooled (Student) t): 6.0705 · Degrees of freedom (df): 18 · p-value: p < 0.001

Two groups with different variances

Group A has a mean of 50.60 and a standard deviation of 1.51, while group B has a mean of 50.00 and a standard deviation of 17.48. Levene's test gives W = 33.866; p < 0.001, so the variances are not homogeneous and the Welch t is reported: t = 0.108; df = 9.13; p = 0.916. The difference is only 0.60 units and the 95% confidence interval runs from -11.92 to 13.12, so it includes zero.

t statistic (Welch-corrected t): 0.1081 · Degrees of freedom (df): 9.13 · p-value: p = 0.916

Comparison from summary statistics

Comparing x̄₁ = 82 (s₁ = 8, n₁ = 25) with x̄₂ = 76 (s₂ = 9, n₂ = 25), the variance ratio test gives F = 1.266; p = 0.568 and the variances are treated as homogeneous. The pooled t = 2.491; df = 48; p = 0.016, so H₀ is rejected. The 95% confidence interval for the difference runs from 1.16 to 10.84; with Cohen d = 0.705 the effect is medium.

t statistic (pooled (Student) t): 2.4914 · Degrees of freedom (df): 48 · p-value: p = 0.016

Frequently Asked Questions

How do I choose between the pooled t and the Welch t?
The classical approach is to check homogeneity of variance with Levene's test first: report the pooled t if p ≥ 0.05 and the Welch t if p < 0.05. In recent years, however, many methodologists recommend the Welch test as the default, because it has almost the same power when the variances are equal and protects the Type I error rate when they are not. This calculator shows both values and marks the recommended one.
Why is Levene's test computed around the median?
The median-centered version is the Brown–Forsythe (1974) correction, and it keeps the Type I error much closer to the nominal level on skewed distributions or in the presence of outliers. The original mean-centered Levene test is reliable only when the groups are approximately normal. The "Based on Median" row in SPSS reports exactly this value.
Do the groups have to be the same size?
No, the test works with unbalanced groups. However, when the group sizes differ a great deal (for instance one is four times the other), the pooled t becomes markedly sensitive to inequality of variance. In that situation the Welch t should be preferred even if the variances look homogeneous.
When should I report Hedges g instead of Cohen d?
Cohen d systematically overstates the true effect size in small samples. Hedges g corrects that bias with the factor J = 1 − 3/(4(n₁+n₂)−9) and makes a noticeable difference when the total sample is below 50. In large samples J approaches 1, so the two measures are practically identical; in meta-analyses g is the standard choice.
Can I compare more than two groups with this test?
No. Comparing three groups with pairwise t-tests inflates the Type I error rate quickly: across three comparisons the real false positive risk is about 14%, not 5%. For three or more groups, run a one-way ANOVA, and if it is significant, make the pairwise comparisons with post-hoc tests such as Tukey or Bonferroni.
Which test should I use if the normality assumption is violated?
If the within-group distributions are clearly non-normal and the samples are small, the Mann–Whitney U test is the nonparametric alternative; it compares rank sums instead of means. If the samples are large (n ≥ 30 in each group), the central limit theorem makes the t-test robust to moderate departures from normality. Outliers should be examined separately in any case.
How do I get the same result in SPSS and R?
In SPSS, Analyze → Compare Means → Independent-Samples T Test produces two rows: "Equal variances assumed" corresponds to the pooled t and "Equal variances not assumed" to the Welch t. In R, t.test(x, y, var.equal = TRUE) gives the pooled result while the default t.test(x, y) gives Welch. The fractional degrees of freedom come from the Welch–Satterthwaite approximation.