Category

t-test Calculator | Formula | p-value – One-sample, Two-sample & Paired

Free t-test calculator for one-sample, two-sample (Welch's and pooled), and paired t-tests. Compute the t-statistic, degrees of freedom, and p-value with step-by-step formulas.

0 calculations

Calculation Parameters

Unchecked: Welch's t-test (recommended). Checked: pooled t-test (assumes equal variances).

Enter Parameters

Fill in the form on the left and click "Calculate"

What is a t-test?

A t-test is one of the most popular statistical tests for location, dealing with the population(s) mean value(s). It is a statistical technique for measuring the difference between the mean values of one and two sample datasets by considering hypothesis testing. It is also known as the Student's t-test and is applied when data has a normal distribution, and the population variance is unknown.

The t-test uses t-statistics, t-distribution values, and degrees of freedom to obtain the critical value for a given significance level. The t-distribution curve can be approximated by a normal curve as the sample size grows, and is further categorized as one-tailed (right tail and left tail) and two-tailed.

Remember that a t-test can only be used for one or two groups. If you need to compare three or more means, use the analysis of variance (ANOVA) method.

The t-test is a parametric test, meaning that your data has to fulfill some assumptions:

  • The data points are independent; AND
  • The data, at least approximately, follow a normal distribution.

If your sample doesn't fit these assumptions, you can resort to nonparametric alternatives, such as the Mann–Whitney U test or the Wilcoxon signed-rank test.

Types of t-tests

One-sample t-test

Choose the one-sample t-test to check if the mean of a population is equal to some pre-set hypothesized value.

Examples:

  • The average volume of a drink sold in 0.33 l cans — is it really equal to 330 ml?
  • The average weight of people from a specific city — is it different from the national average?

Two-sample t-test

Choose the two-sample t-test to check if the difference between the means of two populations is equal to some pre-determined value when the two samples have been chosen independently of each other. In particular, you can use this test to check whether the two groups are different from one another. Also referred to as an independent samples t-test or unpaired samples t-test.

Examples:

  • The average difference in weight gain in two groups of people: one group was on a high-carb diet and the other on a high-fat diet.
  • The average difference in the results of a math test from students at two different universities.

Paired t-test

A paired t-test is used to investigate the change in the mean of a population before and after some experimental intervention, based on a paired sample — i.e., when each subject has been measured twice: before and after treatment.

Examples:

  • The change in student test performance before and after taking a course.
  • The change in blood pressure in patients before and after administering some drug.

How to do a t-test

  1. Decide on the alternative hypothesis: Use a two-tailed t-test if you only care whether the population mean agrees or disagrees with a pre-set value. Use a one-tailed t-test if you want to test whether this mean is greater or less than the pre-set value.
  2. Compute your t-score: Formulas include the sample size, as well as its mean and standard deviation. The exact formula depends on the t-test type.
  3. Determine the degrees of freedom: The degrees of freedom are the number of observations in a sample that are free to vary as you estimate statistical parameters.
  4. Find the p-value using the t-distribution with your degrees of freedom.
  5. Compare the p-value with your significance level α (commonly 0.05). If p < α, reject the null hypothesis.

One-sample t-test formula

The one-sample t-test formula is:

t = (x̄ − μ₀) / (s / √n)

where:

  • — sample mean
  • μ₀ — hypothesized population mean
  • s — sample standard deviation
  • n — sample size
  • df = n − 1 — degrees of freedom

Two-sample t-test formula

For the Welch's t-test (unequal variances — the default):

t = (x̄₁ − x̄₂) / √(s₁²/n₁ + s₂²/n₂)

Degrees of freedom are computed using the Welch–Satterthwaite equation.

For the pooled t-test (equal variances assumed):

t = (x̄₁ − x̄₂) / (s_p × √(1/n₁ + 1/n₂)),   s_p = √[((n₁−1)s₁² + (n₂−1)s₂²) / (n₁+n₂−2)]

df = n₁ + n₂ − 2

Paired t-test formula

t = d̄ / (s_d / √n)

where:

  • — mean of the paired differences
  • s_d — standard deviation of the paired differences
  • n — number of pairs
  • df = n − 1

p-value from t-test

The p-value is the probability (under the null hypothesis) that the test statistic produces values at least as extreme as the computed t-score. A small p-value means the data are unlikely if the null hypothesis is true.

  • p < 0.001 — very strong evidence against H₀
  • p < 0.01 — strong evidence against H₀
  • p < 0.05 — moderate evidence against H₀ (commonly used threshold)
  • p < 0.10 — weak evidence against H₀
  • p ≥ 0.10 — insufficient evidence to reject H₀

t-test vs Z-test

Use the t-test when the population variance is unknown and the sample size is small (typically n < 30). Use the Z-test when the population variance is known, or when you have a very large sample (n > 30) where the t-distribution approximates the normal distribution.

As the degrees of freedom increase, the t-distribution converges to the standard normal distribution N(0,1).

How to use our t-test calculator

  1. Select the test type: one-sample, two-sample, or paired.
  2. Select the tail type: two-tailed, left-tailed, or right-tailed.
  3. Enter the required statistics (means, standard deviations, sample sizes).
  4. Click Calculate to get the t-statistic, degrees of freedom, and p-value.
  5. Review the significance table to see whether to reject H₀ at common α levels.

FAQs

What does a significant t-test result mean?

A significant result (p < α) means there is sufficient statistical evidence to reject the null hypothesis. It does not tell you the practical importance (effect size) of the difference.

What is the null hypothesis in a t-test?

For a one-sample t-test: H₀: μ = μ₀ (the population mean equals the hypothesized value). For a two-sample t-test: H₀: μ₁ = μ₂ (the two population means are equal). For a paired t-test: H₀: μ_d = 0 (the mean difference is zero).

What are degrees of freedom in a t-test?

Degrees of freedom (df) represent the number of independent pieces of information in a sample. For a one-sample or paired t-test, df = n − 1. For a pooled two-sample t-test, df = n₁ + n₂ − 2. For Welch's t-test, df is estimated using the Welch–Satterthwaite equation.

What is the difference between a one-tailed and two-tailed t-test?

A two-tailed test checks whether the mean is either significantly greater or less than the hypothesized value. A one-tailed test checks only one direction (either greater than or less than). One-tailed tests have more statistical power to detect an effect in the specified direction.

When should I use Welch's t-test vs the pooled t-test?

Use Welch's t-test (unequal variances) by default — it is more robust and performs well even when variances are equal. Use the pooled t-test only when you have strong theoretical reasons to assume equal population variances.

Calculation History

Loading...