Calculate the t statistic (t value), degrees of freedom and p-value for a one-sample, two-sample or paired t test, or find the p-value from a t value.

Use the sample SD. With a known population SD, use a z test instead.

Optional settings

Calculator Functions

FunctionWhat it doesWhat it requires
One-sample t testFinds the t statistic for one sample mean against a hypothesized meanRequires the sample mean, the hypothesized mean μ₀, the sample standard deviation and the sample size
Two independent samplesFinds the t statistic for the difference between the means of two separate groups, by Welch's method or the pooled methodRequires the mean, sample standard deviation and sample size of each group. A hypothesized difference is optional and counts as 0 when blank
Paired-sample t testFinds the t statistic for the mean of paired differences, such as before and after valuesRequires the mean paired difference, the sample standard deviation of the differences and the number of pairs. A hypothesized paired difference is optional
P-value from a t statisticFinds the p-value for a t statistic that is already knownRequires the t statistic and its degrees of freedom

Every function also asks for the alternative hypothesis (two-sided, right-sided or left-sided) and a significance level α of 0.05, 0.01 or 0.10. The three test functions return the t statistic with its degrees of freedom, p-value, standard error and the decision at α. Sample sizes must be whole numbers of at least 2, and standard deviations must be greater than zero.

T Statistic Formulas

t = (x̄ − μ₀) ÷ (s ÷ √n) [1]
tThe t statistic, also called the t value
x̄Sample mean
μ₀Hypothesized mean under the null hypothesis
sSample standard deviation, not the population standard deviation
nSample size

Each function follows the same pattern: a difference divided by its standard error. The t statistic counts how many standard errors the observed value lies from the hypothesized one, and its sign follows the order of subtraction.

One-sample t test

The formula above applies directly, with n − 1 degrees of freedom [1]. A sample of 25 with a mean of 52 and a standard deviation of 5, tested against a hypothesized mean of 50, gives t = (52 − 50) ÷ (5 ÷ √25) = 2 with 24 degrees of freedom. The two-sided p-value is 0.0569 and the right-sided p-value is 0.0285.

Two independent samples

t = (x̄₁ − x̄₂ − d₀) ÷
√(s₁² ÷ n₁ + s₂² ÷ n₂) [2]

This is Welch's method, which does not assume the two groups have equal variances. The difference is Group 1 minus Group 2, and d₀ is the hypothesized difference. Its degrees of freedom come from the Welch–Satterthwaite formula and are usually not a whole number [2]:

df = (a + b)² ÷
(a² ÷ (n₁ − 1) +
b² ÷ (n₂ − 1))

Here a = s₁² ÷ n₁ and b = s₂² ÷ n₂. The pooled method assumes equal population variances and replaces the standard error [2]:

SE = sp × √(1 ÷ n₁ + 1 ÷ n₂)

The pooled variance is sp² = ((n₁ − 1)s₁² + (n₂ − 1)s₂²) ÷ (n₁ + n₂ − 2), and the degrees of freedom are n₁ + n₂ − 2. For group means of 20 and 18, standard deviations of 3 and 4 and sample sizes of 15 and 12, Welch's method gives t = 1.4384 with 19.95 degrees of freedom, and the pooled method gives t = 1.4858 with 25.

Paired-sample t test

t = (d̄ − d₀) ÷ (sd ÷ √n) [3]

d̄ is the mean of the paired differences, sd is the sample standard deviation of those differences and n is the number of pairs, with n − 1 degrees of freedom [3]. Every difference has to be taken in the same order, and sd is not the standard deviation of either set of raw values. A mean difference of 1.2 with a standard deviation of 2 over 16 pairs gives t = 1.2 ÷ (2 ÷ √16) = 2.4.

P-value from a t statistic

The p-value is the probability, when the null hypothesis is true, of a t statistic at least as extreme as the one observed [4]. It is read from the Student t distribution with the entered degrees of freedom, which may be fractional. A two-sided p-value is twice the area in the tail beyond |t|. A right-sided p-value is the area above t, and a left-sided p-value is the area below t. For t = 2.4 with 15 degrees of freedom, the two-sided p-value is 0.0298. The null hypothesis is rejected when p is less than α [4].

How to Calculate a T Statistic

Subtract the hypothesized mean from the sample mean, divide the sample standard deviation by the square root of the sample size to get the standard error, then divide the first result by the second. With a sample mean of 45, a hypothesized mean of 50, a sample standard deviation of 2.5 and a sample size of 400: the difference is 45 − 50 = −5, the standard error is 2.5 ÷ √400 = 0.125, and t = −5 ÷ 0.125 = −40. The negative sign shows the sample mean is below the hypothesized mean.

Limits of This Estimate

  • A t test assumes the data come from a single process, are roughly normally distributed and are not correlated with one another [5]. Summary numbers cannot show whether those conditions hold.
  • The t statistic uses the sample standard deviation. When the population standard deviation is known, a z test applies instead.
  • A small p-value is not the probability that the null hypothesis is true, and it does not measure how large or important a difference is. Failing to reject the null hypothesis does not prove the means are equal.
  • P-values are computed for degrees of freedom from 1 to 1,000,000. The standardized difference in the results is the difference divided by a standard deviation, for description only; for two independent samples it uses the pooled standard deviation even under Welch's method.

Sources

  1. NIST/SEMATECH e-Handbook of Statistical Methods, Section 1.3.5.2, Confidence Limits for the Mean: one-sample t statistic and its n − 1 degrees of freedom
  2. NIST/SEMATECH e-Handbook of Statistical Methods, Section 1.3.5.3, Two-Sample t-Test for Equal Means: unequal-variance and pooled statistics, pooled variance and both degrees of freedom formulas
  3. NIST, Dataplot Reference Manual, T TEST: paired t statistic from the standard deviation of the differences, with n − 1 degrees of freedom
  4. NIST/SEMATECH e-Handbook of Statistical Methods, Section 7.1.3.1, Critical values and p values: meaning of the p-value and rejecting when it is smaller than α
  5. NIST/SEMATECH e-Handbook of Statistical Methods, Section 7.1.2, What assumptions are typically made?: assumptions behind the tests