T-Test Calculator
Compare a sample against a hypothesized mean, or compare two independent samples, to get the t-statistic and p-value.
Calculator verified • Last updated: August 2026
—
The t-Distribution, Visually
The shaded regions mark where a t-statistic would be considered extreme enough to reject the null hypothesis. If your marked t-statistic lands inside a shaded region, the difference is statistically significant.
How to Calculate a T-Test
A one-sample t-test compares your sample mean to a fixed hypothesized value, scaled by how much variability you'd expect just from sampling. A two-sample t-test compares two independent group means the same way, using a pooled estimate of variance from both groups.
One-sample t:
t: the t-statistic.
x̄: the sample mean.
μ0: the hypothesized population mean you're testing against.
s: the sample standard deviation.
n: the sample size.
Two-sample t:
x̄1, x̄2: the means of the two samples.
sp²: the pooled variance across both samples.
n1, n2: the sizes of the two samples.
The resulting t-statistic is then compared against the t-distribution with the appropriate degrees of freedom (n − 1 for one-sample, n₁ + n₂ − 2 for the pooled two-sample test) to get a p-value.
One-Sample vs. Two-Sample Tests
Use a one-sample t-test when you're checking a single group against a known benchmark — for example, whether a new manufacturing process produces parts with a mean weight different from the 100g specification. Use a two-sample t-test when comparing two independent groups directly, like a treatment group versus a control group, with no assumption about what the "correct" value should be.
Reading the Result
A larger absolute t-statistic means the observed difference is large relative to the variability in your data, making it less likely to be due to chance. The p-value translates that t-statistic into a probability: if it falls below your chosen significance level (commonly 0.05), the difference is typically called "statistically significant" — though as with any significance test, this says nothing on its own about how large or practically meaningful the difference actually is.
Assumptions Behind the T-Test
The standard t-test assumes your data is approximately normally distributed (or your sample is large enough that this matters less), that observations are independent of each other, and — for the two-sample version used here — that both groups have roughly equal variances (this pooled-variance approach is often called Student's t-test, as opposed to Welch's t-test which doesn't require equal variances).
A Brief History of the T-Test
The t-test was developed by William Sealy Gosset, a chemist and statistician working for the Guinness brewery in Dublin in the early 1900s, who needed a reliable way to draw conclusions from very small sample sizes — a common situation in brewery quality control, where testing was often destructive or expensive. Guinness had a policy at the time restricting employees from publishing research that might reveal trade secrets, so Gosset published his 1908 paper under the pseudonym "Student," which is why the underlying distribution is still called the Student's t-distribution today. His key insight was that the normal distribution's assumptions break down with small samples, and he derived a new distribution — with heavier tails to account for the added uncertainty of estimating variance from limited data — that became foundational to modern small-sample statistics. Ronald Fisher later refined and popularized Gosset's work in the 1920s, cementing the t-test as one of the most widely used tools in applied statistics.
Common T-Test Mistakes
Running a t-test on data that clearly violates its assumptions — heavily skewed distributions, non-independent observations (like repeated measurements on the same subjects treated as separate data points) — without considering an alternative test is a common error that can produce misleading results. Confusing a statistically significant result with a practically meaningful one is another: with a large enough sample, even a tiny, unimportant difference can become statistically significant, so it's worth looking at the effect size alongside the p-value. Using a paired test's logic on unpaired data (or vice versa) is a third frequent mistake, since paired and independent-samples t-tests make different assumptions about how the two groups relate to each other.
T-Test Terms You Should Know
T-Statistic — a standardized measure of how far apart two sample means are, relative to the variability within the samples.
Degrees of Freedom — a value derived from the sample size(s) that determines the exact shape of the t-distribution used to calculate the p-value.
Pooled Variance — a combined estimate of variance from two samples, used in Student's t-test when the samples are assumed to have equal variances.
Effect Size — a measure of the magnitude of a difference between groups, independent of sample size, often reported alongside a t-test's p-value.
Frequently Asked Questions
What is the difference between a one-sample and two-sample t-test?
A one-sample t-test compares a single sample's mean against a known or hypothesized value. A two-sample (independent) t-test compares the means of two separate, unrelated samples to see if they differ.
What does the t-statistic measure?
The t-statistic measures how many standard errors the observed difference is from zero (or from the hypothesized value). A larger absolute t-statistic means the observed difference is less likely to be due to random chance alone.
What assumptions does a t-test make?
A standard t-test assumes the data is roughly normally distributed (or the sample is large enough for the Central Limit Theorem to apply), observations are independent, and for a two-sample test, that both groups have similar variances.
Should I use a t-test or a z-test?
Use a t-test whenever the population standard deviation is unknown and estimated from the sample, which is true in nearly all real-world cases. A z-test is only appropriate when the true population standard deviation is genuinely known in advance.