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
Example 2 - Two-Sample t-Test
Example 3 - Paired t-Test (Before/After)
Example 4 - Welch's t-Test
❓ Frequently Asked Questions
🔗 Related Calculators
What is a t-test?
A t-test is a statistical hypothesis test used to determine if there is a significant difference between means. It uses the t-distribution, which accounts for the extra uncertainty from estimating the population standard deviation from a sample. The t-test is used when the population standard deviation is unknown and the sample size is relatively small (though it works for large samples too).
When should I use a t-test vs a Z-test?
Use a t-test when the population standard deviation (σ) is unknown and must be estimated from the sample (s). Use a Z-test when σ is known, or for large samples (n > 30) where the t-distribution approximates the normal. In practice, σ is almost never known, so the t-test is almost always appropriate for comparing means.
What is Welch's t-test?
Welch's t-test is a two-sample t-test that does not assume equal population variances. It adjusts the degrees of freedom using the Welch-Satterthwaite equation to account for unequal variances. It is more robust than Student's t-test and is recommended when the two groups have different standard deviations.
What is the difference between a one-tailed and two-tailed t-test?
A two-tailed test checks if the means differ in either direction (H₁: μ₁ ≠ μ₂). A one-tailed test checks a specific direction (H₁: μ₁ > μ₂ or H₁: μ₁ < μ₂). Two-tailed is more conservative and is the default in most research. Use one-tailed only when you have a strong prior reason to expect a difference in a specific direction.
What is a paired t-test?
A paired t-test (also called dependent samples t-test) is used when two sets of observations are linked - for example, measurements on the same subjects before and after an intervention, or matched pairs in an experiment. It computes the difference for each pair and performs a one-sample t-test on those differences. This removes between-subject variability, making it more powerful than an independent two-sample test.
How do I interpret the t-test results?
If p < α (e.g., 0.05): reject H₀ - there is a statistically significant difference between the means. If p > α: fail to reject H₀ - insufficient evidence for a difference. Also check the effect size (Cohen's d): d < 0.2 is negligible, 0.2–0.5 is small, 0.5–0.8 is medium, > 0.8 is large.
What are the assumptions of the t-test?
The t-test assumes: (1) the data is approximately normally distributed (or n is large enough by CLT); (2) for two-sample tests, the groups are independent; (3) for the equal-variance t-test, both populations have the same variance. The paired t-test requires the differences to be approximately normal.
What is the degrees of freedom for a t-test?
One-sample: df = n − 1. Two-sample (equal variance): df = n₁ + n₂ − 2. Welch's (unequal variance): df calculated by Welch-Satterthwaite formula, typically between min(n₁,n₂)−1 and n₁+n₂−2. Paired: df = n_pairs − 1.