Statistics & Data Analysis

Student’s t-test

Run one-sample, Welch or pooled independent, and paired t-tests from observations or summaries; inspect the mean difference, SE, p-value and interval.

Question, try, then observe

The same mean gap: the same evidence?

Two independent samples have means 50 plus the gap and 50. Predict whether increasing dispersion alone preserves the absolute t statistic.

01 · Make a predictionWith a fixed mean gap, does more dispersion leave |t| unchanged?
Alternative direction
Significance level α

H₀: μA−μB=0 · H₁: μA−μB ≠ 0 · Welch

Student’s t · reference distribution

df=38 · α=0.05 · p=0.1221

Student’s t · reference distributionDensity curve. Statistic 1.581, p 0.1221, alpha 0.05. Solid area is the observed tail; hatched area is the planned rejection region. Read exact critical values below.Density-404
Observed tail (solid)α rejection region (hatched)Statistic: dotted · Critical: dashed
Statistic: 1.581Critical value(s): -2.024, 2.024The drawing truncates long tails. Probabilities use the complete distribution, not the displayed area.

Welch SE: square root of the sum of each group's variance divided by its size

SE=6220+6220≈1.8974

Subtract the null difference of zero, then divide by SE

t=3−01.8974≈1.5811
  1. The p-value uses the current degrees of freedom, alternative and t distribution, not a normal critical value.
Mean difference3points; original effect units
SE of the difference1.897
t1.581df=38
p-value0.1221

95% confidence interval: -0.841 to 6.841

Do not reject H₀ at the selected α; this does not prove H₀ true.

The same people before and after: why retain pairing?

Each row is one student. Baseline ability varies greatly, while within-student improvements vary less. Paired t uses the six after−before differences. The independent calculation only illustrates the effect of ignoring structure; it is not the appropriate choice for these observations.

StudentBeforeAfterAfter−before
146493
262664
354562
478835
570733
660644
Retain pairingSE=0.428t=8.174 · p=0.0004
Ignore pairing (illustration)SE=6.758t=0.518 · p=0.6158

What did you just see?

A three-minute difference may stand out in precise measurements but be difficult to distinguish in noisy ones. Compare the gap with uncertainty in the estimate, not just with zero.

Define the question first

For one sample, H₀ specifies a population mean μ₀. Independent and paired tests usually specify a mean difference Δ₀. H₁ may be unequal, greater or less. Choose α, the planned Type I error rate, and the direction before examining the outcome.

SD, SE and effect size

Sample SD describes individual dispersion; SE describes sampling variation in the estimate. A tiny mean difference can become significant in a large sample while remaining unimportant. Ask how large the difference is, how uncertain it is and whether it changes a decision.

Independent and paired observations

Two groups of different units need an independent-sample method. Before–after observations on the same units need aligned differences. Handle missing pairs together; independently removing blanks and pairing the remaining rows changes the data.

Conditions for t inference

Observations or pair differences should be representative and independent. Small samples need approximately normal errors without severe outliers. Larger samples do not automatically fix selection bias, serial dependence or heavy tails. More trading days are not necessarily more independent information.

Another example

  1. Choose one-sample and enter data or n=20, mean=53 and sample SD=6.
  2. Set μ₀=50 and α=0.05; choose the alternative before looking at results.
  3. Read the estimated difference, SE, df, p-value and matching interval, then check sampling assumptions.
Show formal definition and formula

A t-test uses sample dispersion to estimate uncertainty in a mean or mean difference when population SD is unknown, then compares the statistic with a Student’s t reference distribution.

One-sample and paired differences

Welch mean difference and SE

Pooled equal variance and two-sided interval

H₀ / H₁
Null and alternative; choose direction before inspecting data.
x̄, μ₀, s, n
Sample mean, null mean, sample SD and count.
vA, vB, ν
sA²/nA, sB²/nB and Welch degrees of freedom, which can be fractional.
sp², SE
Pooled variance and standard error; pooling assumes equal variances.
dᵢ, δ₀
Paired A−B difference and null difference.
α, p
Preset significance level and extremeness probability under the null model.

Common mistakes

Failing to reject H₀ does not prove no difference, and a small p-value does not establish a large effect. Ignoring before–after pairing or choosing a one-tail direction after inspecting data changes the question and error rate.

Frequently asked questions

Why is Welch the independent-sample default?

Welch allows unequal population variances and uses a separate SE contribution from each group with approximate df. Pooled t adds an equal-variance assumption; equal sample sizes alone do not justify it.

How does pairing change the test?

A paired test is a one-sample t-test of within-unit differences. Shared individual variation may cancel, but the differences still need independence and suitable distribution assumptions.

Why is a one-tail interval one-sided?

A directional alternative has a one-sided confidence bound and an unbounded opposite end. The tool labels that end as unbounded rather than inventing a finite number. Two-sided tests have two-sided intervals.

You can now explore…

  • Compare mean differences with standard error
  • Distinguish pairing, Welch and test direction