Written and maintained by CASRAI Editorial Board
Last updated
Quick answer: the p-value of a Student’s t-test is the area in the tails of the t distribution beyond your t statistic, using the test’s degrees of freedom. For a two-sided test, double the upper-tail area at |t|. In the worked example below, t = 2.55 on 20 degrees of freedom gives p = .019 two-sided and p = .0095 one-sided.
Definition in one paragraph
In a Student’s t-test, the p-value is the probability, computed under the null hypothesis, of obtaining a t statistic at least as extreme as the one observed. You do not read it from the raw data directly: you first reduce the data to a t statistic and a degrees-of-freedom value, then ask how much of the t distribution lies beyond that statistic. Most mistakes come from mixing up which tail area to use. For what the resulting number does and does not tell you, see our guide to interpreting t-test results; this page covers the calculation.
Formula: from data to t, df and p, with every symbol explained
For the two-sample test for unpaired data, the NIST/SEMATECH e-Handbook of Statistical Methods defines the null hypothesis as H0: μ1 = μ2 and the test statistic as:
T = (Ȳ1 − Ȳ2) / √(s1²/N1 + s2²/N2)
- Ȳ1, Ȳ2: the two sample means.
- s1², s2²: the two sample variances (the squared standard deviations).
- N1, N2: the two sample sizes.
- ν (nu): the degrees of freedom. NIST gives the Welch-Satterthwaite formulation for ν and notes that if equal variances are assumed and the sample sizes are similar, ν = N1 + N2 − 2. See two-sample t-test degrees of freedom: pooled vs Welch for both.
- p: a tail area of the t distribution with ν degrees of freedom. Two-sided: p = 2 × P(tν > |T|). One-sided: p = P(tν > T) when the alternative is μ1 > μ2, or P(tν < T) when it is μ1 < μ2.
The equal-variance version replaces the denominator with a pooled estimate: sp² = [(N1 − 1)s1² + (N2 − 1)s2²] / (N1 + N2 − 2) and T = (Ȳ1 − Ȳ2) / (sp √(1/N1 + 1/N2)). The pooled standard deviation is sp.
Worked example: from t and degrees of freedom to the p-value
Suppose group 1 has N1 = 12, mean 24.5 and standard deviation 4.2, and group 2 has N2 = 10, mean 20.1 and standard deviation 3.8. The two-sided hypothesis is H0: μ1 = μ2.
- Pooled variance. sp² = (11 × 4.2² + 9 × 3.8²) / 20 = (194.04 + 129.96) / 20 = 324 / 20 = 16.2, so sp = 4.025.
- Standard error. 4.025 × √(1/12 + 1/10) = 4.025 × √0.18333 = 4.025 × 0.42817 = 1.7234.
- t statistic. (24.5 − 20.1) / 1.7234 = 4.4 / 1.7234 = 2.553, reported as 2.55.
- Degrees of freedom. 12 + 10 − 2 = 20.
- Upper-tail area. P(t20 > 2.553) = 0.0095.
- Two-sided p. 2 × 0.0095 = 0.0189, reported as p = .019.
The same value comes out of R’s pt(), Excel’s T.DIST.2T and SciPy (code below).
One-tailed vs two-tailed p-value
The tail you use is set by the alternative hypothesis you chose before seeing the data. NIST states the matching rejection regions: for a two-sided test (Ha: μ1 ≠ μ2), reject when |T| > t1−α/2, ν; for Ha: μ1 > μ2, reject when T > t1−α, ν; for Ha: μ1 < μ2, reject when T < tα, ν.
| Alternative hypothesis | Area used for p | Example (T = 2.553, ν = 20) |
|---|---|---|
| μ1 ≠ μ2 (two-sided) | 2 × upper-tail area beyond |T| | p = .019 |
| μ1 > μ2 (upper one-sided) | Upper-tail area beyond T | p = .0095 |
| μ1 < μ2 (lower one-sided) | Lower-tail area below T | p = .991 (T is on the wrong side) |
The lower one-sided entry is 1 − 0.0095 = 0.9905. It shows why the direction must be fixed in advance: the same data give p = .0095 for one alternative and p = .99 for the opposite one.
The degrees of freedom change p
The same t statistic gives a different p-value for different degrees of freedom, because the t distribution has heavier tails when ν is small. With T = 2.55, the two-sided p is .019 at ν = 20 and .051 at ν = 5. In our example the Welch-Satterthwaite approach, which does not assume equal variances, gives T = 2.578 on ν ≈ 19.83 and p = .018, close to the pooled result because the groups are similar in size and spread. The two tests can diverge much more when variances and sample sizes are both unequal.
Interpretation: p and the critical value are the same test
Comparing p with the significance level α and comparing |T| with the critical value are equivalent, which is the NIST rejection rule restated: |T| > t1−α/2, ν exactly when two-sided p < α. With ν = 20 and α = .05 the critical value is 2.086, and our T = 2.553 exceeds it, so p < .05. Our guide to finding a critical value shows the lookup route.
| Result | Reading |
|---|---|
| p < α (equivalently |T| > critical value) | Reject H0 at level α |
| p ≥ α (equivalently |T| ≤ critical value) | Do not reject H0 at level α |
| Any p | A p-value is a tail area, not a measure of how large the difference is; give the group means and their difference alongside it |
Assumptions and common mistakes
- Using the wrong tail. Doubling a one-sided area, or failing to double it, changes p by a factor of two. Fix the alternative before looking at the data.
- Using the wrong degrees of freedom. N1 + N2 − 2 is for the pooled test; use the Welch-Satterthwaite value if variances differ.
- Passing a negative t to a function that needs |t|. Excel’s
T.DIST.2Trequires a non-negative first argument, so wrap it inABS(). - Reading the p-value as an effect size. A small p can come from a trivial difference in a large sample.
- Ignoring the model. The tail area is only valid when the t distribution is the right reference, which depends on independent observations and approximately normal data, as covered in our t-test overview.
How to report it (APA example)
APA style reports the test, its degrees of freedom in parentheses, the statistic and the p-value. For the example above: t(20) = 2.55, p = .019. The APA Style numbers and statistics guide says to report exact p values to two or three decimals and to report values below .001 as p < .001, not p = .000. See how to report p-values.
How to calculate it in Excel, R or Python
Excel
=T.DIST.2T(ABS(2.55), 20) // two-sided, 0.0191
=T.DIST.RT(2.55, 20) // upper one-sided, 0.0095
R
R’s pt() is the cumulative distribution function of the t distribution, and lower.tail = FALSE returns P[X > x].
t_stat <- 2.55; df <- 20
2 * pt(abs(t_stat), df, lower.tail = FALSE) # 0.0191
pt(t_stat, df, lower.tail = FALSE) # 0.0095
Python
SciPy’s ttest_ind returns the statistic, p-value and degrees of freedom; equal_var=False gives Welch’s test, and alternative can be 'two-sided', 'less' or 'greater'. From a t statistic alone, use the survival function:
from scipy import stats
t_stat, df = 2.55, 20
p_two = 2 * stats.t.sf(abs(t_stat), df) # 0.0191
p_one = stats.t.sf(t_stat, df) # 0.0095
# from summary statistics (pooled, equal variances)
stats.ttest_ind_from_stats(24.5, 4.2, 12, 20.1, 3.8, 10, equal_var=True)
The last line returns t = 2.553 and p = 0.0189. Our guide to running a t-test in R covers the raw-data workflow.
FAQ
How do I find the p-value from a t-score?
You need the t statistic, the degrees of freedom and the alternative hypothesis. Compute the upper-tail area of the t distribution beyond |t| and double it for a two-sided test, using T.DIST.2T in Excel, pt() in R or t.sf() in SciPy.
What does the p-value mean in a Student’s t-test?
It is the tail probability of a t statistic at least as extreme as yours if the null hypothesis is true. It is not the probability that the null hypothesis is true.
Is the two-tailed p-value always twice the one-tailed value?
Yes when the one-tailed value is taken in the direction of the observed difference, because the t distribution is symmetric about zero.
Why does the same t give a different p with different degrees of freedom?
The t distribution has heavier tails at low degrees of freedom, so the same t statistic cuts off more area. The t distribution guide shows the shape.
Sources
- NIST/SEMATECH e-Handbook of Statistical Methods, section 1.3.5.3, Two-Sample t-Test for Equal Means: itl.nist.gov/div898/handbook/eda/section3/eda353.htm (checked 2026-10-29).
- SciPy documentation,
scipy.stats.ttest_ind: docs.scipy.org (checked 2026-10-29). - R documentation, The Student t Distribution (
stats::TDist): stat.ethz.ch/R-manual (checked 2026-10-29). - Microsoft Support, T.DIST.2T function: support.microsoft.com (checked 2026-10-29).
- American Psychological Association, APA Style numbers and statistics guide: apastyle.apa.org/instructional-aids/numbers-statistics-guide.pdf (checked 2026-10-29).







