Compare means calculator

Student's two-sample t-test calculator

Calculate standard Student's two-sample t-test assuming equal variances, including pooled standard variance, t-statistic, p-value, and confidence intervals.

Run this test live in StatLab npm i @statlab/core

When to use it

Use when comparing two independent groups known or verified to have equal population variances.

Required Inputs

  • Group A numeric values
  • Group B numeric values
  • Confidence level
  • Alternative hypothesis

Mathematical Formula

t = (X̄₁ - X̄₂) / (s_p * √(1/n₁ + 1/n₂)), where s_p² = ((n₁-1)s₁² + (n₂-1)s₂²) / (n₁ + n₂ - 2)

Reporting Cautions

  • If Levene’s or Bartlett’s test shows variance inequality, switch to Welch’s t-test.
  • Sensitive to skewness in small sample sizes.

Code Snippets (Python, R, TypeScript)

Python (SciPy / Statsmodels)
from scipy import stats
res = stats.ttest_ind(group_a, group_b, equal_var=True)
print(f"t={res.statistic:.4f}, p={res.pvalue:.4f}")
R Language
t.test(group_a, group_b, var.equal = TRUE)
TypeScript (@statlab/core)
import { tInd } from '@statlab/core';
const result = tInd(groupA, groupB, { equalVar: true });

Developer Use Cases & Production Integrations

  • Testing mean difference between balanced control and treatment groups under equal variance assumptions.
  • Comparing baseline microbenchmarks across identical hardware configurations.

VoxelPulse Telemetry Control Plane

Continuous A/B testing, statistical telemetry analysis, and automated feedback loops for live backend services.

Explore VoxelPulse →

VoxelAssurance Release Readiness

Fixed-price AI release-readiness sprints, automated regression testing, and reliability statistical benchmarks.

Explore VoxelAssurance →

Related Statistical Test Calculators

Explore static calculators across the StatLab inference engine suite.