Course contentsShow
← Data Science
Lesson 319 of 2,1459. Hypothesis Testing FoundationsFree lesson

Calculating P-Values from Test Statistics

Convert test statistics to p-values using cumulative distribution functions and reference distributions.

Calculating P-Values from Test Statistics

What you'll learn: How to transform a test statistic into a p-value using probability distributions.

The Connection Between Test Statistics and P-Values

You've already learned what a test statistic is (a standardized measure of how far your sample result is from the null hypothesis) and what a p-value represents (the probability of seeing results as extreme as yours if the null hypothesis is true). Now we connect them.

The test statistic tells you where you landed on a reference distribution. The p-value tells you how unusual that location is.

How the Calculation Works

Every test statistic follows a known probability distribution under the null hypothesis—Z follows a standard normal, t follows a t-distribution, etc. These distributions come with cumulative distribution functions (CDFs) that tell you the probability of getting a value at or below a certain point.

To find the p-value:

  1. Calculate your test statistic (you learned this in lesson 316)
  2. Identify the reference distribution (standard normal for Z, t-distribution for t, etc.)
  3. Use the CDF to find the area beyond your test statistic

For a two-sided test, you calculate the probability in both tails (values as extreme or more extreme in either direction). For a one-sided test, you only care about one tail direction.

Simple Example

If your Z test statistic is 2.5 in a two-sided test, you find the area beyond 2.5 in both directions. The CDF tells you about 99.38% of values fall below 2.5, so 0.62% are above. Double that for both tails: p-value ≈ 0.0124.

Key Takeaway: P-values are calculated by using cumulative distribution functions to measure how far into the tails of the reference distribution your test statistic falls—transforming a number into a probability of extremeness.