How to use the t-test calculator
- Select the test type: one-sample, two-sample or paired.
- Enter the required summary statistics such as means, standard deviations and sample sizes.
- For a one-sample test, provide the hypothesized population mean (μ₀).
- Read the computed t-statistic, degrees of freedom and two-tailed p-value below the form.
How the t-statistic is calculated
The formula depends on the design of your test. For a one-sample t-test, the t-statistic compares the sample mean to a known value:
t = (x̄ - μ₀) / (s / √n)
Suppose you measured 30 items with a mean of 52.3, a standard deviation of 5.1, and want to test against μ₀ = 50. The standard error is 5.1 / √30 = 0.9311. The t-statistic is (52.3 - 50) / 0.9311 = 2.4701.
For an independent two-sample t-test assuming equal variances, the pooled standard deviation combines both groups:
s_p = √(((n₁-1)s₁² + (n₂-1)s₂²) / (n₁+n₂-2))
The t-statistic is then t = (x̄₁ - x̄₂) / (s_p √(1/n₁ + 1/n₂)) with n₁ + n₂ - 2 degrees of freedom.
For a paired t-test, you first compute the difference for each pair, then treat those differences as a single sample tested against zero: t = d̄ / (s_d / √n).
From t-statistic to p-value
The t-statistic alone does not tell you whether a result is statistically significant. You need the p-value, which is the probability of observing a t-statistic at least as extreme as yours if the null hypothesis were true. This t test calculator computes the exact two-tailed p-value using the regularized incomplete beta function applied to the Student's t-distribution.
A common threshold is α = 0.05. If the p-value falls below this cutoff, researchers typically reject the null hypothesis. Keep in mind that statistical significance does not automatically imply practical importance. Always consider the effect size and the context of your data alongside the p-value.
When to use each t-test variant
Choosing the correct variant matters because each makes different assumptions about your data structure.
- One-sample t-test: Use when you have a single group and want to compare its mean to a known or hypothesized value. Example: testing whether a batch of parts has an average length different from the specification.
- Independent two-sample t-test: Use when comparing the means of two separate groups that have no relationship to each other. Example: comparing exam scores between students taught with two different methods. This calculator uses the pooled-variance version, which assumes both populations share the same variance.
- Paired t-test: Use when each observation in one group is naturally linked to an observation in the other, such as before-and-after measurements on the same subjects. Example: measuring blood pressure before and after a treatment in the same patients.
Assumptions and common mistakes
The Student's t-test relies on several assumptions. Violating them can lead to misleading results.
- Normality: The data (or the differences, for a paired test) should be approximately normally distributed. The t-test is robust to mild departures from normality when sample sizes are moderate or large, but small samples from heavily skewed distributions can produce inaccurate p-values.
- Equal variances: The pooled two-sample test assumes both groups have the same population variance. If variances differ substantially, Welch's t-test is more appropriate. This tool uses the classic pooled approach.
- Independence: Observations within each group must be independent of one another. Using a two-sample test on paired data inflates the degrees of freedom and understates the p-value.
A frequent mistake is entering the standard error instead of the standard deviation. The standard deviation measures spread in the raw data, while the standard error is the standard deviation divided by the square root of n. Double-check which value your software or textbook provides.
Quick reference table
The table below shows critical t-values for a two-tailed test at α = 0.05 across common degrees of freedom. If your computed t-statistic exceeds the critical value, the result is significant at the 5 percent level.
| Degrees of freedom | Critical t (α = 0.05, two-tailed) |
|---|---|
| 5 | 2.571 |
| 10 | 2.228 |
| 15 | 2.131 |
| 20 | 2.086 |
| 30 | 2.042 |
| 60 | 2.000 |
| 120 | 1.980 |
As degrees of freedom increase, the t-distribution approaches the standard normal distribution, and the critical value converges toward 1.960.
Worked examples
Each result below was produced by the same code the tool runs, so you can check your own numbers against them.
| Example | Input | Result |
|---|---|---|
| One-sample test | Test type: one; Sample mean (x̄): 52.3; Hypothesized mean (μ₀): 50; Standard deviation (s): 5.1; Sample size (n): 30 | t-statistic: 2.4701; Degrees of freedom: 29; p-value (two-tailed): 0.0196; Standard error: 0.9311 |
| Two-sample test | Test type: two; Mean of group 1 (x̄₁): 78.2; Std dev of group 1 (s₁): 10.5; Size of group 1 (n₁): 25; Mean of group 2 (x̄₂): 72.1; Std dev of group 2 (s₂): 11.2; Size of group 2 (n₂): 25 | t-statistic: 1.9867; Degrees of freedom: 48; p-value (two-tailed): 0.0527; Pooled std dev: 10.8556; Standard error: 3.0704 |
| Paired test | Test type: paired; Mean difference (d̄): 3.4; Std dev of differences (s_d): 2.1; Number of pairs (n): 20 | t-statistic: 7.2406; Degrees of freedom: 19; p-value (two-tailed): 0.0000; Standard error: 0.4696 |
FAQ
What is a t test calculator used for?
It computes the t-statistic and p-value to determine whether the difference between means is statistically significant. Researchers and students use it to evaluate hypotheses without manual lookup tables.
What is the difference between a one-sample and a two-sample t-test?
A one-sample t-test compares a single group's mean to a fixed reference value. A two-sample t-test compares the means of two independent groups against each other.
When should I use a paired t-test instead of a two-sample test?
Use a paired t-test when each data point in one group corresponds directly to a data point in the other, such as repeated measurements on the same subject. A two-sample test is for unrelated groups.
Does this tool assume equal variances for the two-sample test?
Yes. The two-sample calculation uses the pooled variance method, which assumes both populations have the same variance. If your groups have very different variances, consider Welch's t-test instead.
What does the p-value mean in a t-test?
The p-value is the probability of obtaining a t-statistic as extreme as the one observed, assuming the null hypothesis is true. A small p-value suggests the observed difference is unlikely due to chance alone.
Is my data sent to a server when I use this t test calculator?
No. All computations happen locally in your browser. Nothing you type is uploaded anywhere.
Can I use this for very small sample sizes?
Yes, the t-test was designed for small samples. However, with fewer than about 15 observations per group, the normality assumption becomes more important, so verify your data is roughly symmetric.