Two Sample t‑Test Calculator

Compare the means of two independent samples with this comprehensive t‑test calculator. Choose between Student's t‑test (equal variance) and Welch's t‑test (unequal variance). Get the t‑statistic, degrees of freedom, p‑value, confidence interval, and Cohen's d effect size. Visualize the t‑distribution with critical regions.

Separate values with commas, spaces, or newlines.
Separate values with commas, spaces, or newlines.
If sample sizes or variances differ greatly, Welch's test is the safer default.
? Drug efficacy: A(12,15,14,16,13) B(10,11,9,12,10)
? Test scores: A(78,82,85,79,81) B(70,73,68,72,71)
? Production yield: A(98,102,97,99,101) B(95,93,96,94,92)
? Crop yield: A(3.2,3.5,3.1,3.4,3.3) B(2.8,3.0,2.9,2.7,2.6)
? Reaction time: A(0.45,0.47,0.44,0.46,0.48) B(0.52,0.55,0.50,0.53,0.51)
Privacy first: All calculations are performed locally in your browser. No data is sent to any server.

Understanding the Two‑Sample t‑Test

The two‑sample t‑test (also known as the independent samples t‑test or Student's t‑test) is a statistical procedure used to determine whether the means of two independent groups are significantly different from each other. It is one of the most widely used tools in empirical research, from clinical trials to A/B testing in business.

t = ?1?2 / ( sp2 ( 1/n1 + 1/n2 ) )

where sp2 is the pooled variance (Student's version).

When to Use This Tool

  • A/B Testing: Compare conversion rates, click‑through rates, or user engagement metrics between two groups.
  • Clinical Research: Evaluate the efficacy of a treatment versus a control group.
  • Quality Control: Compare production yields or defect rates between two manufacturing processes.
  • Educational Assessment: Compare test scores between two teaching methods.
  • Psychology & Social Sciences: Compare reaction times, survey scores, or behavioral metrics across conditions.

Statistical Foundations & Derivation

The two‑sample t‑test was introduced by William Sealy Gosset in 1908 under the pseudonym "Student" while working at the Guinness Brewery. Gosset's original formulation assumed equal variances between groups. The Welch's t‑test, developed by B. L. Welch in the 1930s, relaxes the equal‑variance assumption and is generally preferred when sample sizes or variances differ.

The test statistic compares the difference between sample means relative to the standard error of that difference. Under the null hypothesis (H₀: μ₁ = μ₂), the statistic follows a t‑distribution with degrees of freedom determined by the method used. The p‑value quantifies the probability of observing a test statistic as extreme as the one computed, assuming the null hypothesis is true.

Assumptions of the Test

  • Independence: Observations within and between samples are independent.
  • Normality: The populations from which samples are drawn are approximately normally distributed (robust for moderate deviations).
  • Homogeneity of variance (Student's): The variances of the two populations are equal (Welch's does not require this).
  • Random sampling: Samples are drawn randomly from their respective populations.
  • Measurement scale: The dependent variable is continuous (interval or ratio scale).

Practical tip: Use our built-in variance ratio check (F-test) to guide your choice between Student's and Welch's test. For normality, consider the Shapiro-Wilk test (available in our Normality Test Calculator).

Step‑by‑Step Calculation

  1. Compute sample statistics: Calculate the mean, variance, and sample size for each group.
  2. Choose the test variant: If variances are equal, use Student's t‑test with pooled variance. Otherwise, use Welch's t‑test.
  3. Calculate the t‑statistic: The numerator is the difference between means; the denominator is the standard error.
  4. Determine degrees of freedom: For Student's: n₁ + n₂ − 2. For Welch's: the Satterthwaite approximation.
  5. Find the p‑value: Using the t‑distribution with the computed df, find the probability of the observed t‑value under H₀.
  6. Make a decision: Compare the p‑value with the chosen significance level (α). Reject H₀ if p < α.

Worked Examples

Case Study 1: Pharmaceutical Efficacy

A pharmaceutical company tests a new drug designed to lower blood pressure. Two independent groups are recruited: the treatment group (n = 15, mean = 118.5 mmHg, SD = 6.2) and the placebo group (n = 14, mean = 124.3 mmHg, SD = 7.1). Using a two‑sided t‑test with α = 0.05, the calculated t‑statistic is −2.41 with 27 degrees of freedom (Student's). The p‑value is 0.023, indicating a statistically significant difference. The company can conclude that the drug is effective in lowering blood pressure.

Case Study 2: A/B Testing in E‑Commerce

An e‑commerce platform tests two website layouts: Layout A (n = 500, conversion rate = 3.2%) and Layout B (n = 480, conversion rate = 4.1%). Since the data are proportions, a two‑sample t‑test is applied to the underlying continuous metrics (e.g., time on site). The Welch's t‑test yields t = 2.87, df = 45.6, p = 0.006. The result is statistically significant at α = 0.01, so the platform adopts Layout B to boost conversions.

The Satterthwaite Approximation (Welch's df)

When variances are unequal, the degrees of freedom are calculated using the Satterthwaite formula, which accounts for the sample sizes and variances of both groups:

df ≅ ( s₁²/n₁ + s₂²/n₂ )² / ( (s₁²/n₁)²/(n₁−1) + (s₂²/n₂)²/(n₂−1) )

This approximation yields a non‑integer df that is generally smaller than n₁ + n₂ − 2, providing a more conservative test when variances differ substantially. Welch's test is robust and recommended as a default in modern statistical practice.

Common Misconceptions

  • t‑test requires large samples: The t‑test is designed for small samples (n < 30) and is appropriate for any sample size, provided the normality assumption is reasonable.
  • p < 0.05 means the effect is large: Statistical significance does not imply practical significance. Always consider the effect size and confidence interval.
  • Equal variance must always be assumed: Welch's t‑test does not require equal variances and is often the safer choice.
  • Non‑normal data cannot be analyzed: The t‑test is robust to moderate violations of normality, especially with larger samples (central limit theorem). For severe violations, non‑parametric alternatives (e.g., Mann‑Whitney U test) may be considered.

Application Across Fields

  • Medicine: Compare treatment vs. control groups in randomized controlled trials.
  • Business Analytics: Evaluate the impact of marketing campaigns, pricing changes, or product features.
  • Engineering: Compare material strengths, process yields, or performance metrics.
  • Environmental Science: Compare pollutant levels, species abundance, or climate measurements across sites.
  • Sports Analytics: Compare player performance metrics across teams or training regimens.

Grounded in statistical theory – This tool implements the Student's t‑test and Welch's t‑test as formalized by Gosset (1908) and Welch (1938). The algorithms follow the recommendations of the American Statistical Association and are consistent with standard textbooks (e.g., Casella & Berger, "Statistical Inference"; Montgomery, "Design and Analysis of Experiments"). The interactive visualization uses the t‑distribution density function computed with high‑precision numerical methods. Reviewed by the GetZenQuery tech team, last updated June 2026.

Frequently Asked Questions

Student's t‑test assumes equal variances between groups and uses a pooled variance estimate. Welch's t‑test does not assume equal variances and uses the Satterthwaite approximation for degrees of freedom. Welch's test is more robust and is recommended when variances or sample sizes differ.

Use a two‑tailed test when you are interested in any difference (either direction). Use a one‑tailed test when you have a specific directional hypothesis (e.g., Group A mean > Group B mean). One‑tailed tests have more power to detect an effect in the specified direction.

The t‑test is robust to moderate non‑normality, especially with larger samples (n ≥ 30 per group). For small samples or severe deviations, consider non‑parametric alternatives like the Mann‑Whitney U test or use transformations (e.g., log, square root) to approximate normality.

A confidence interval provides a range of plausible values for the true difference between means. For a 95% CI, we say that if we repeated the experiment many times, 95% of the intervals would contain the true difference. If the interval does not contain zero, the result is statistically significant at α = 0.05.

No. This calculator is for independent samples (two distinct groups). For paired or repeated‑measures data, please use our Paired t‑Test Calculator.

Cohen's d standardizes the mean difference by the pooled standard deviation. Unlike the p‑value, it is not affected by sample size and directly measures the practical significance of your result. Generally, d = 0.2 is considered small, 0.5 medium, and 0.8 large. Reporting effect size is essential for meaningful interpretation of research findings.

Explore authoritative resources such as Khan Academy, Penn State STAT 415, or the textbooks "Introduction to the Practice of Statistics" by Moore, McCabe, and Craig.
References: Wikipedia: Student's t‑test; Welch, B. L. (1938). "The significance of the difference between two means when the population variances are unequal"; NIST Handbook: t‑Test.