This simulator generates random samples with a seeded PRNG (splitmix32 + Box-Muller), then computes a real t-statistic for three designs — one-sample, two-sample (pooled or Welch), and paired. It draws the t-distribution's PDF via a log-gamma/incomplete-beta approximation, shades the rejection regions at your chosen α, and reports p-value, 95% confidence interval, Cohen's d effect size, and statistical power live as you move any slider.
The top canvas plots your simulated data points (with jitter) against the null hypothesis or the other group's mean; the bottom canvas draws the t(df) sampling distribution with the two-tailed critical regions and your observed t-statistic marked on it.
Pick a tab — One-Sample, Two-Sample, or Paired — then drag sample size n, means μ, standard deviation σ, or mean difference δ, and choose a significance level α. Try the preset buttons (Drug trial, Learning, Null true, Small n) to jump to instructive scenarios, or toggle Equal variances to switch between the pooled Student's t and Welch's t formulas.
The Welch two-sample formula computes degrees of freedom with the Welch-Satterthwaite equation, which is why df can come out as a non-integer estimate rather than the tidy n₁+n₂−2 of the pooled version — it's the standard fix when the two groups don't share the same variance.
The one-sample test compares a single simulated sample's mean against a fixed null value μ₀ using t = (x̄ − μ₀)/(s/√n). The two-sample test compares two independently generated groups A and B, using either the pooled formula (equal variances assumed) or Welch's formula (unequal variances). The paired test generates matched before/after values and tests whether their mean difference d̄ differs from zero.
The simulator computes the two-tailed p-value from the t-distribution CDF, which is evaluated via a regularized incomplete beta function using a continued-fraction (Lentz) approximation and a Stirling log-gamma routine — the same numerical machinery statistics libraries use, implemented directly in the page's JavaScript.
The p-value only tells you whether a difference is statistically detectable given your sample size; Cohen's d measures how large that difference is in standardized units (mean difference divided by pooled or sample standard deviation). The simulator labels d as negligible, small, medium, or large so you can see effect size and significance can disagree, especially at very large or very small n.
With Equal variances checked, the two-sample test pools both groups' variances into one estimate and uses df = n₁+n₂−2 (Student's t). Unchecked, it switches to Welch's t, which weights each group's variance separately and computes df via the Welch-Satterthwaite approximation — more robust when group sizes or spreads differ.
Each control redraws the plot by regenerating a fresh random sample from a seeded PRNG (splitmix32) combined with a Box-Muller normal transform. The seed is reset before each update so results stay reproducible for a given preset, while still feeling like fresh random data compared to the underlying true population parameters you set.