T-Test Calculator
Compute a one-sample or two-sample t-test from raw data or summary statistics. Enter your values, choose the alternative hypothesis and significance level, and get the t-statistic, degrees of freedom, p-value and conclusion.
Run a T-Test
T-Test Formula
Where:
- \(\bar{x}\) — sample mean
- \(\mu_0\) — hypothesized population mean under H0
- \(s\) — sample standard deviation (with \(n - 1\) in the denominator)
- \(n\) — sample size
- \(\bar{x}_1, \bar{x}_2\), \(s_1, s_2\), \(n_1, n_2\) — means, SDs and sizes of the two independent samples
The t-statistic measures how many standard errors the sample mean lies from the value hypothesized under H0. It is compared against the Student t distribution with \(df\) degrees of freedom to obtain the p-value: the probability of observing a result at least this extreme if H0 were true. For a two-tailed test, \(p = 2\,P(T_{df} \ge |t|)\); one-tailed tests use a single tail. If the pooled variance option is selected for two samples, the standard error uses the pooled variance \(s_p^2\) and \(df = n_1 + n_2 - 2\).
T-Test – Calculation Example
{shortcode_start}
Example: a machine is supposed to fill bottles to 100 ml. Ten fill volumes are measured: 99.2, 98.7, 100.3, 101.1, 99.5, 98.9, 100.8, 99.6, 100.2, 97.9. Is the mean fill different from 100 ml at \(\alpha = 0.05\)? (These are the calculator's default values.)
\[ n = 10, \quad \bar{x} = \frac{996.2}{10} = 99.62, \quad s = \sqrt{\frac{\sum (x_i - \bar{x})^2}{n - 1}} \approx 0.994 \]
\[ t = \frac{99.62 - 100}{0.994/\sqrt{10}} = \frac{-0.38}{0.314} \approx -1.209, \quad df = 10 - 1 = 9 \]
\[ p = 2\,P(T_9 \ge |-1.209|) \approx 0.258 \]
Result: \(t \approx -1.209\), \(df = 9\), \(p \approx 0.258\). Since \(p > 0.05\), we fail to reject H0: there is no statistically significant evidence that the mean fill differs from 100 ml.
{/shortcode_start}
How to Use the T-Test Calculator
- Under Test settings, choose the Test type: one-sample (compare a sample mean with a hypothesized value) or two-sample (compare two independent sample means).
- Select the Alternative hypothesis (H1) — two-tailed (\(\neq\)), right-tailed (\(>\)) or left-tailed (\(<\)) — and the Significance level (\(\alpha\)): 0.05, 0.01 or 0.10.
- For a one-sample test, enter the Hypothesized mean (\(\mu_0\)).
- For a two-sample test, choose the Variance assumption: Welch (unequal variances, the safer default) or pooled (equal variances).
- Set the Input mode. With Raw data, paste your values into Sample data (and Sample 2 data for a two-sample test), separated by spaces, semicolons or new lines. With Summary statistics, enter the mean, standard deviation and sample size for each sample.
- Read the t-statistic, degrees of freedom, p-value and the Conclusion stating whether H0 is rejected at your chosen \(\alpha\).
What Is a T-Test and How to Interpret the Result
A t-test is a statistical hypothesis test that compares a mean (or the difference between two means) to a claimed value when the population standard deviation is unknown and must be estimated from the sample. This is the typical situation with small datasets in science, quality control, medicine and A/B testing. The resulting t-statistic expresses the observed difference in units of standard error; values far from zero suggest the data contradict the null hypothesis.
The p-value answers the question: if the null hypothesis were true, how likely is a result at least as extreme as the one observed? A small p-value means the data would be surprising under H0, providing evidence against it. By convention, the result is called statistically significant when \(p \le \alpha\) (usually 0.05), and H0 is rejected. A large p-value does not prove H0 true — it only means there is not enough evidence against it.
Choose the tail direction based on your research question. A two-tailed test checks for any difference (\(\mu \ne \mu_0\)). A right-tailed test asks whether the mean is greater than the hypothesized value; a left-tailed test asks whether it is smaller. One-tailed tests are more powerful in their chosen direction but must be justified before looking at the data — switching tails afterward inflates the false-positive rate.
For two independent samples, the calculator offers Welch's test by default. It does not assume equal variances and uses the Welch–Satterthwaite approximation for the degrees of freedom, which is more reliable when the two samples have different spreads or sizes. The pooled version is appropriate only when the populations are believed to have equal variances.
Assumptions, Limitations and Practical Tips
- Normality: the t-test assumes the underlying population (or the residuals) is roughly normally distributed. With small samples, check a histogram or normality plot; with large samples (roughly \(n \ge 30\)), the central limit theorem makes the test robust to moderate non-normality. Heavily skewed data with outliers calls for a non-parametric alternative.
- Independence: observations must be independent of each other. Paired or repeated-measures data (before/after on the same subjects) should not be analyzed with a two-sample test — use the differences in a one-sample test on the paired differences instead.
- Sample size: at least 2 values per sample are required, and values must not all be identical (SD = 0). Small samples give wide uncertainty, so a non-significant result may simply reflect low power — see the Sample Size Calculator when planning a study.
- Significance vs. importance: a tiny p-value only says the difference is unlikely to be zero, not that it is large or practically meaningful. Always report the effect size, and complement the test with a Confidence Interval Calculator to see the plausible range of the mean difference.
- Raw data vs. summary statistics: raw data lets the calculator compute the mean and SD for you (with an \(n-1\) denominator); summary mode is handy when reading published results. To check individual values, the Standard Deviation Calculator and the Z-Score Calculator (for known \(\sigma\) or large samples) are useful companions.
Frequently Asked Questions
What is a good or significant t-statistic value?
There is no universal "good" t-value — its meaning depends on the degrees of freedom and whether your test is one- or two-tailed. Roughly, with about 20 degrees of freedom a two-tailed t beyond ±2.09 is significant at \(\alpha = 0.05\). Larger \(|t|\| values indicate stronger evidence against the null hypothesis. Always judge significance by the p-value rather than the t-statistic alone.
How do I calculate a t-statistic by hand?
For a one-sample test, subtract the hypothesized mean from your sample mean, then divide by the standard error \(s/\sqrt{n}\). First compute the mean, then the sample standard deviation using an \(n-1\) denominator. For example, with \(\bar{x} = 12\), \(\mu_0 = 10\), \(s = 3\), \(n = 9\): \(t = (12-10)/(3/\sqrt{9}) = 2\). Compare against the t-distribution with \(df = n-1\) to get the p-value.
Should I use a one-tailed or two-tailed t-test?
Use a two-tailed test when any difference matters (higher or lower). Use a one-tailed test only when you specified a directional prediction before collecting data — for example, "the new drug lowers blood pressure." Choosing the tail after seeing the result artificially inflates the false-positive rate. If in doubt, the two-tailed test is the conservative and widely accepted choice in most research settings.
What is the difference between a t-test and a z-test?
A z-test is used when the population standard deviation \(\sigma\) is known or when samples are very large; a t-test is used when \(\sigma\) must be estimated from the sample, which adds uncertainty. The t-distribution has heavier tails than the normal distribution, especially with few degrees of freedom. As \(n\) grows (roughly beyond 30), the two tests give nearly identical results.
Can I use a t-test with paired or before/after data?
Not as a regular two-sample test. Paired measurements — such as blood pressure before and after treatment on the same people — violate the independence assumption. Instead, compute the difference for each subject and run a one-sample t-test on those differences, testing whether their mean equals zero. Using an independent two-sample test on paired data usually loses statistical power.
Why does my p-value differ slightly from other software?
Small differences usually come from rounding in the inputs or from different variance assumptions. Check whether the other tool used pooled variances while this one used Welch, or whether it assumed equal variances by default (as Excel's T.TEST with type 2 does). Rounding the standard deviation to fewer decimals before entering it can also shift the t-statistic and p-value noticeably, so enter full precision.
What sample size do I need for a t-test to be valid?
Technically the test works with as few as 2 observations, but very small samples have low power and are sensitive to non-normality. With \(n \ge 30\), the central limit theorem makes the test fairly robust even for skewed data. For planning, the required sample size depends on the effect size you want to detect, the significance level, and the desired power — a power analysis is the proper way to choose it.