T-Test Calculator
Free t-test calculator for one-sample, two-sample & paired t-tests. Calculate t-value, p-value, degrees of freedom with step-by-step results.
What is a T-Test?
A t-test is a statistical test used to compare means. It helps determine whether there’s a significant difference between group means or between a sample mean and a known value.
Types of T-Tests
One-Sample T-Test
Compares a sample mean to a known or hypothesized population mean.
Use when: Testing if your sample differs significantly from a standard or expected value.
Two-Sample T-Test (Independent)
Compares the means of two independent groups.
Use when: Comparing two separate groups (e.g., treatment vs. control).
Paired T-Test
Compares means from the same group at different times or under different conditions.
Use when: Comparing before/after measurements on the same subjects.
T-Test Formulas
One-Sample T-Test
t = (x̄ - μ₀) / (s / √n)
Two-Sample T-Test (Welch’s)
t = (x̄₁ - x̄₂) / √(s₁²/n₁ + s₂²/n₂)
Understanding the Results
- T-statistic: Measures the size of the difference relative to variation
- Degrees of freedom: Related to sample size(s)
- P-value: Probability of observing results if null hypothesis is true
- Significance: If p-value < α (e.g., 0.05), the result is statistically significant
Assumptions of T-Tests
- Data is approximately normally distributed
- Random sampling from the population
- Independence of observations
- For two-sample: Similar variances (unless using Welch’s t-test)
One-Sample T-Test: When and How
A one-sample t-test compares a sample mean to a known or hypothesized population value. Use it when you want to test whether your data differs from a specific standard.
Example: A manufacturer claims light bulbs last 1,000 hours. You test 25 bulbs and find a mean of 980 hours with s = 40. Is the mean significantly different from 1,000?
- H₀: μ = 1,000 hours
- H₁: μ ≠ 1,000 hours
- t = (980 − 1000) / (40 / √25) = −20 / 8 = −2.50
- df = 25 − 1 = 24
- From the t-table: t-critical at α=0.05 (two-tailed) = 2.064
- Since |−2.50| > 2.064, reject H₀ — the bulbs last significantly less than 1,000 hours.
Paired T-Test: Before-and-After Comparisons
A paired t-test (dependent samples t-test) compares two related measurements on the same subjects — for example, before and after a treatment.
Example: 12 students took a math test, then completed a tutoring program, and took the test again.
| Student | Before | After | Difference (d) |
|---|---|---|---|
| 1 | 72 | 78 | +6 |
| 2 | 65 | 70 | +5 |
| 3 | 80 | 82 | +2 |
| … | … | … | … |
- Calculate the mean difference: d̄ = 4.2
- Calculate the SD of differences: s_d = 2.1
- t = d̄ / (s_d / √n) = 4.2 / (2.1 / √12) = 6.93
- df = 12 − 1 = 11
- This is highly significant — the tutoring program worked.
When to use: Pre/post measurements, matched pairs, same subjects under two conditions.
Independent Two-Sample T-Test: Comparing Two Groups
An independent (two-sample) t-test compares means from two separate, unrelated groups.
Example: A pharmaceutical company tests a new drug against a placebo.
- Drug group (n₁ = 30): mean = 8.2, s₁ = 1.5
- Placebo group (n₂ = 30): mean = 6.8, s₂ = 1.8
- H₀: μ₁ = μ₂ (no difference between groups)
- H₁: μ₁ ≠ μ₂
- t = (8.2 − 6.8) / √(1.5²/30 + 1.8²/30) = 1.4 / 0.429 = 3.26
- Degrees of freedom (Welch’s): df ≈ 56
- p-value < 0.01 — the drug shows a significant effect.
When to use: Treatment vs. control, comparing two independent groups, A/B testing results.
Which T-Test Should You Use?
| Scenario | Test | df |
|---|---|---|
| Compare sample to known value | One-sample | n − 1 |
| Before/after on same subjects | Paired | n − 1 |
| Two independent groups | Two-sample (Welch’s) | Complex formula |
| Two groups, equal variances assumed | Two-sample (pooled) | n₁ + n₂ − 2 |
Not sure? Start with How to Choose the Right Statistical Test.
Frequently Asked Questions
What is a t-test used for?
A t-test is used to compare means and determine if there’s a statistically significant difference between them. Use a one-sample t-test to compare a sample mean to a known value, two-sample to compare two independent groups, and paired to compare before/after measurements.
How do I calculate the t-value?
For a one-sample t-test: t = (sample mean - hypothesized mean) / (sample SD / √n). For two-sample: t = (mean₁ - mean₂) / √(s₁²/n₁ + s₂²/n₂). This calculator does the computation automatically.
What is a good t-value?
There’s no single “good” t-value—it depends on degrees of freedom and significance level. Generally, |t| > 2 suggests significance at α=0.05 for moderate sample sizes. Compare your t-value to the critical value from the t-table.
What does the p-value mean in a t-test?
The p-value is the probability of getting results as extreme as yours if there’s actually no difference (null hypothesis is true). p < 0.05 means there’s less than 5% chance the difference is due to random sampling—typically considered statistically significant.
When should I use a paired t-test vs independent t-test?
Use a paired t-test when the same subjects are measured twice (before/after, matched pairs). Use an independent t-test when comparing two separate groups with different subjects. The paired test is more powerful because it controls for individual differences.
When should I use t-test vs z-test?
Use t-test when population standard deviation is unknown (most real-world situations). Use z-test when population σ is known or sample size is very large (n > 100). The t-test is more conservative and appropriate for smaller samples.
What is the difference between one-tailed and two-tailed t-test?
A two-tailed test checks if means are different (either direction). A one-tailed test checks if one mean is specifically greater or less than the other. Use two-tailed unless you have a strong directional hypothesis before collecting data.
What is Welch’s t-test?
Welch’s t-test is a two-sample t-test that does not assume equal variances between groups. It adjusts degrees of freedom based on sample sizes and variances, making it more reliable than the pooled t-test when group sizes or variances differ.
Related Tools
- t-Table - Look up critical t-values
- Z-Score Calculator - Standardize values
- Mean Calculator - Calculate sample means
- Standard Deviation Calculator - Calculate standard deviations
- Confidence Interval Calculator - Build confidence intervals
- Degrees of Freedom Reference - df formulas for every test
Want to learn the theory?
Our lessons explain the statistical concepts behind this calculator with clear examples.
Browse Lessons →