t-Test Calculator

Run a complete t-test with p-value, test statistic, degrees of freedom, and interpretation.

t t-Test Calculator
t-Statistic
-
Degrees of Freedom
-
p-Value
-
Critical Value
-

📖 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

One-sample: t = (x̄ − μ₀) / (s / √n)

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

1
Select the test type: One-sample (compare to reference), Two-sample (compare two groups), Welch's (unequal variances), or Paired (matched pairs).
2
Enter the sample mean(s), standard deviation(s), and sample size(s). For paired tests, compute the differences first and enter the mean and SD of the differences.
3
Choose the tail type (two-tailed for most research) and significance level α. Click Run t-Test.
4
Compare the t-statistic to the critical value, or use the p-value directly. If p < α, reject H₀.

📝 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.

Result = t = 1.369, p ≈ 0.183 (Not Significant)
Try this example →

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.

Result = t ≈ 2.17, p ≈ 0.034 (Significant)
Try this example →

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.

Result = t = 3.08, p ≈ 0.003 (Significant)
Try this example →

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.

Result = t ≈ 1.24, p ≈ 0.232 (Not Significant)
Try this example →

❓ Frequently Asked Questions

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.