t-Test Calculator
One-sample and two-sample t-tests with t-statistic, degrees of freedom, p-value, critical value, and a plain-English accept/reject decision — full step-by-step working included.
Running test...
Select a test type, enter your sample statistics, and click Run — the t-statistic, p-value, and decision appear instantly.
How a t-Test Works
The t-test follows a fixed decision process. Each step below feeds into the next.
Step 1
Collect Sample Data
x̄, s, n (and μ₀ or second group x̄₂, s₂, n₂)
Step 2
Compute t-Statistic
Step 3
Find Degrees of Freedom
Step 4
Calculate p-Value from t-Distribution
p = area in the tail(s) beyond |t| under the t-distribution with df degrees of freedom
Step 5
Compare p to α
p < α
Reject H₀
Result is statistically significant
p ≥ α
Fail to Reject H₀
Insufficient evidence to reject
What Is a t-Test?
A t-test is a statistical hypothesis test that determines whether an observed difference between means is likely to be real or simply the result of random sampling variation. Unlike a z-test, which requires a known population standard deviation and large samples, the t-test works with small samples by using an estimated standard deviation and the heavier-tailed t-distribution.
The test produces a t-statistic — a standardised measure of how many standard errors the observed mean is from the null hypothesis value. The t-statistic is then compared against the t-distribution with the appropriate degrees of freedom to compute a p-value: the probability of observing a result at least this extreme if the null hypothesis were true.
t-tests are among the most widely used statistical procedures in social science research, clinical trials, quality control, and A/B testing. They are appropriate when the data are approximately normally distributed (or the sample size is large enough for the Central Limit Theorem to apply) and the observations are independent.
One-Sample t-Test: Formula and When to Use It
The one-sample t-test compares the mean of a single sample against a known or hypothesized population mean (μ₀). Use it when you have one group of measurements and want to test whether that group is consistent with a benchmark value.
Common applications: comparing a class's average test score against the national average, checking whether a batch of products meets a target weight specification, testing whether a coin-flip experiment deviates from 50% heads, or verifying that a treatment group's resting heart rate matches the healthy population norm.
Formula
SE = s / √n
t = (x̄ − μ₀) / SE
df = n − 1
Where x̄ is the sample mean, s is the sample standard deviation, n is the sample size, and μ₀ is the hypothesized population mean. With 25 observations, a sample mean of 5.2, a hypothesized mean of 5.0, and a standard deviation of 0.4, you get t = 2.500 on 24 degrees of freedom — a p-value of roughly 0.020, which is statistically significant at the 5% level.
Two-Sample t-Test: Comparing Two Group Means
The two-sample t-test determines whether two independent groups have different population means. This calculator uses Welch's t-test, which does not assume that the two groups have equal variances. This makes it more broadly applicable than Student's classic equal-variance t-test.
Common applications: A/B testing two versions of a landing page, comparing exam scores between two teaching methods, testing whether a drug lowers blood pressure more than a placebo, or comparing average transaction values between two customer segments.
Welch's Formula
SE = √(s₁²/n₁ + s₂²/n₂)
t = (x̄₁ − x̄₂) / SE
df = (s₁²/n₁ + s₂²/n₂)² / ((s₁²/n₁)²/(n₁−1) + (s₂²/n₂)²/(n₂−1))
(Welch–Satterthwaite equation, truncated to integer)
The Welch–Satterthwaite equation adjusts the degrees of freedom downward when the group variances are unequal, giving a more conservative (and correct) test. When both groups have identical variance and sample size, Welch's degrees of freedom equals the Student's t-test value of n₁ + n₂ − 2.
How to Interpret p-Values
The p-value is the probability of observing a t-statistic at least as extreme as the one you computed, assuming the null hypothesis is true. It is not the probability that the null hypothesis is correct.
p < 0.01
Strong evidence against H₀. Used in clinical research and psychology replication studies.
0.01 ≤ p < 0.05
Conventional significance threshold in most social sciences. Reject H₀ at the 5% level.
p ≥ 0.05
Fail to reject H₀. This does not prove the null is true — only that the evidence is insufficient.
A low p-value does not mean the effect is large or practically meaningful. With a very large sample, even a trivially small difference can yield p < 0.001. Always pair p-values with effect sizes (such as Cohen's d) and confidence intervals for a complete picture.
t-Test Assumptions and Limitations
The t-test produces valid results when several conditions are met. Violating these assumptions can inflate the Type I error rate or reduce statistical power.
Independence
Each observation must be drawn independently. Repeated measurements on the same individual violate this — use a paired t-test (which is equivalent to a one-sample test on the differences) instead.
Approximate Normality
The sample means must be approximately normally distributed. The Central Limit Theorem makes this a weak requirement for n ≥ 30; for small samples, the raw data should be roughly bell-shaped.
Continuous Scale
The measurement should be on a continuous (interval or ratio) scale. t-tests are not valid for binary outcomes — use a proportion test instead.
No Outliers
Extreme outliers can distort the mean and inflate the standard deviation, weakening the test. Inspect your data with a boxplot before running any t-test.
t-Test Calculator FAQ
What is the difference between a one-sample and two-sample t-test?
A one-sample t-test compares a single group's mean to a fixed reference value (such as a population norm or specification limit). A two-sample t-test compares the means from two independent groups to each other. The formulas differ because the two-sample test must account for the variability in both groups.
What does the t-statistic tell you?
The t-statistic measures how many standard errors the sample mean is away from the null hypothesis value. A t-statistic of 2 means the observed difference is twice as large as what would be expected from sampling error alone. Larger absolute values of t indicate stronger evidence against the null hypothesis. The sign of t shows the direction — positive means the sample mean is above μ₀, negative means it is below.
How do I interpret a p-value from a t-test?
The p-value answers this question: if the null hypothesis were true, what is the probability of seeing a t-statistic at least this extreme? A p-value of 0.03 means there is a 3% chance of observing your result by random chance alone. If that probability falls below your chosen significance level (usually α = 0.05), you reject the null hypothesis and declare the result statistically significant.
What is the difference between a one-tailed and two-tailed t-test?
A two-tailed test checks whether the mean is different in either direction (higher or lower). A one-tailed test checks only one direction: a right-tailed test asks whether the mean is significantly higher, a left-tailed test whether it is significantly lower. Two-tailed tests are the safe default. Only use a one-tailed test when you have a strong prior reason to care only about one direction — otherwise you risk inflating the Type I error rate.
Why does degrees of freedom matter?
Degrees of freedom (df) determines the exact shape of the t-distribution used to compute the p-value. The t-distribution has heavier tails than a normal distribution, and those tails get lighter as df increases. With df = 5, a t-statistic of 2.0 gives p ≈ 0.10; with df = 100, the same t-statistic gives p ≈ 0.048. Larger samples (more df) provide more statistical power to detect true differences.
What is Welch's t-test and when should I use it?
Welch's t-test is a modification of the two-sample t-test that does not require the two groups to have equal variances. It adjusts the degrees of freedom using the Welch–Satterthwaite equation, which reduces them when the group variances are unequal. Simulations consistently show that Welch's test maintains the correct Type I error rate whether or not the variances are equal, while Student's equal-variance test fails when they are not. Welch's test is therefore the better default for two-sample comparisons.
What are the assumptions of a t-test?
The main assumptions are: (1) independence — observations must be independent of each other; (2) approximate normality — the sampling distribution of the mean must be approximately normal (satisfied by the Central Limit Theorem for n ≥ 30 or by data that are themselves roughly normal for small n); and (3) continuous measurement scale — the t-test is designed for interval or ratio data, not counts or proportions.
Related Calculators
Z-Score Calculator
Standardise a value and find its normal-distribution percentile
Confidence Interval Calculator
Estimate a population mean with z or t critical values
Standard Deviation Calculator
Compute σ, variance, and mean for any list of numbers
Sample Size Calculator
Determine how many observations you need before collecting data
Probability Calculator
Combined event, conditional, and complement probabilities
Binomial Distribution Calculator
P(X=k), P(X≤k), and P(X≥k) for binary experiments