t-Test Calculator
Run a complete t-test with p-value, test statistic, degrees of freedom, and interpretation.
📖 What is a t-Test?
The t-test is one of the most commonly used statistical hypothesis tests. It determines whether the means of one or two groups are significantly different from each other or from a reference value. The test is based on the t-distribution, which was developed by William Sealy Gosset (writing under the pseudonym "Student") in 1908 while working at Guinness Brewery to analyse small samples of barley.
The key advantage of the t-test over the Z-test is that it does not require knowledge of the population standard deviation. Instead, it uses the sample standard deviation (s) as an estimate, and the resulting t-distribution has heavier tails than the normal distribution to account for the extra uncertainty - especially important for small samples.
There are three main variants. The one-sample t-test tests whether a sample mean is different from a known reference value. The two-sample (independent) t-test compares the means of two independent groups. The paired t-test compares means from the same group under two conditions (before/after, two measurements per subject).
The t-test is used in clinical trials (does the drug change mean blood pressure?), psychology (do groups differ on a scale score?), quality control (does a batch meet specifications?), and in A/B testing when comparing two groups' means.
📐 Formulas
Two-sample (equal variance): t = (x̄₁ − x̄₂) / [s_p × √(1/n₁ + 1/n₂)]
where s_p = √[((n₁−1)s₁² + (n₂−1)s₂²) / (n₁+n₂−2)] is the pooled standard deviation
Welch's t-test (unequal variance): t = (x̄₁ − x̄₂) / √(s₁²/n₁ + s₂²/n₂)
Paired t-test: t = d̄ / (s_d / √n)
where d̄ = mean of differences, s_d = standard deviation of differences, n = number of pairs
Degrees of freedom: One-sample/paired: df = n−1. Two-sample equal: df = n₁+n₂−2. Welch's: df ≈ (s₁²/n₁ + s₂²/n₂)² / [(s₁²/n₁)²/(n₁−1) + (s₂²/n₂)²/(n₂−1)]
📖 How to Use This Calculator
📝 Example Calculations
Example 1 - One-Sample t-Test
A sample of 25 students has mean exam score 52.3, SD = 8.4. Is the mean different from μ₀ = 50? α = 0.05, two-tailed.
t = (52.3 − 50) / (8.4 / √25) = 2.3 / 1.68 = 1.369, df = 24
p ≈ 0.183 > 0.05 - Fail to reject H₀. Insufficient evidence the mean differs from 50.
Example 2 - Two-Sample t-Test
Group A: mean=68, SD=10, n=30. Group B: mean=62, SD=11, n=28. α = 0.05, two-tailed.
Pooled SD = √[(29×100 + 27×121) / 56] ≈ 10.49; t = (68−62) / [10.49×√(1/30+1/28)] = 6 / 2.76 ≈ 2.17, df = 56
p ≈ 0.034 < 0.05 - Reject H₀. Groups differ significantly.
Example 3 - Paired t-Test (Before/After)
20 participants' blood pressure before/after treatment. Mean difference = 4.2 mmHg, SD of differences = 6.1. α = 0.05, one-tailed right (H₁: treatment reduces BP).
t = 4.2 / (6.1/√20) = 4.2 / 1.364 = 3.08, df = 19
p ≈ 0.003 < 0.05 - Reject H₀. Treatment significantly reduces blood pressure.
Example 4 - Welch's t-Test
Group 1: mean=105, SD=15, n=18. Group 2: mean=95, SD=25, n=12. α = 0.05, two-tailed.
t = (105−95) / √(225/18 + 625/12) = 10 / √(12.5+52.08) = 10 / 8.04 ≈ 1.24, df (Welch) ≈ 16
p ≈ 0.232 > 0.05 - Fail to reject H₀. Groups do not differ significantly.