A p value is the probability of getting a test result at least as extreme as the one you observed, calculated under the assumption that the null hypothesis is true. A small p value means your data would be unusual if the null hypothesis held, which counts as evidence against it; a large p value means your data are perfectly ordinary under that assumption and gives you no reason to doubt it. So what is p value in statistics? It is not the probability your hypothesis is true, and it is not the probability you made an error — it is a single conditional probability, computed from a test statistic and a sampling distribution, that tells you how surprising your result is.

Key takeaways

Point Details
A p value is a conditional probability It answers "how likely is data this extreme, assuming the null hypothesis is true?" — nothing more and nothing less.
The p-value formula is a tail area For a z or t statistic, the p value is the area under the sampling distribution beyond your observed statistic, doubled for a two-tailed test.
You compare it to a pre-set threshold The decision rule is p < α → reject the null hypothesis; the threshold α (commonly 0.05) must be chosen before you look at the data.
A small p value is not proof of a large effect Statistical significance and practical significance are different claims; always read the p value alongside an effect size.
It is not the probability the null hypothesis is true That common misreading requires a prior probability and Bayes’ theorem, which the standard p-value calculation never supplies.

Quick Checklist: How to Calculate a P-Value

Before you compute anything, lock down four choices — the hypotheses, the test, the tail, and the threshold. Getting any one of them backwards produces a p value that is arithmetically correct but answers the wrong question.

Quick checklist: how to calculate p value

  • State H₀ and H₁ first Write the null and alternative hypotheses before touching the data, so the test direction is not chosen after seeing the result.
  • Pick the right test statistic Use z when the population standard deviation is known; use t, with n − 1 degrees of freedom, when it is estimated from the sample.
  • Match the tail to the alternative A two-sided H₁ needs both tails; a directional H₁ ("greater than" or "less than") needs exactly one.
  • Set α before you compute p Choose the significance level — usually 0.05 — ahead of time so the threshold cannot be moved to fit the result.
  • Compare p to α and report both State the exact p value and the decision, not just "significant" or "not significant."

The rest of this guide walks through each of those steps with real numbers, then covers the formulas, the software shortcuts, and the mistakes that trip up even careful analysts.

What Is a P-Value in Statistics?

A p value measures how compatible your observed data are with a specific null hypothesis, expressed as a probability between 0 and 1. Formally:

p = P( test statistic as extreme or more extreme than observed | H₀ is true )

“As extreme” means in the direction your alternative hypothesis predicts. For a two-tailed test — where you only care that there is a difference, not its direction — “more extreme” covers both tails of the sampling distribution; for a one-tailed test it covers only the tail your alternative points toward.

NIST/SEMATECH’s handbook chapter on statistical tests frames a statistical test as a decision mechanism built on two competing claims: a null hypothesis H₀ and an alternative H₁, with a significance level α set in advance as the acceptable risk of rejecting a true H₀. OpenStax’s Introductory Statistics defines H₀ as the claim assumed true unless the data say otherwise, and H₁ as the claim you are testing for — the null hypothesis article covers how to state each one correctly. The p value is the number that connects your sample to that decision: it is computed from the test statistic, and a p value near 0 says results like yours would be rare under H₀, while a p value near 1 says they would be common.

For a quick mental anchor: flip a coin 20 times and get 15 heads. If the coin were fair, 15 or more heads out of 20 would occur by chance alone about 2% of the time. That 2% is the p value for “is this coin fair?” — small enough that most analysts would start doubting the coin.

What Is the P-Value Formula?

The p-value formula depends on which test statistic you compute, but the logic is identical in every case: convert your sample result into a standardized statistic, then find the tail area of that statistic’s sampling distribution.

The p-value formula by test statistic
Test statistic Formula Two-tailed p-value
z (σ known) z = (x̄ − μ₀) / (σ / √n) p = 2 × P(Z > |z|)
t (σ unknown, df = n − 1) t = (x̄ − μ₀) / (s / √n) p = 2 × P(T > |t|), df = n − 1
One-tailed (right) same statistic as above p = P(Z > z) or P(T > t)
One-tailed (left) same statistic as above p = P(Z < z) or P(T < t)

Use the z formula only when the population standard deviation σ is known from long-run process data; otherwise use the t formula, substituting the sample standard deviation s and looking up the tail area in the Student’s t-distribution instead of the standard normal. NIST/SEMATECH’s table of the standard normal CDF and its table of Student’s t critical values are the reference tables behind each row above. The same tail-area logic extends to proportions, chi-square statistics, and F statistics — only the sampling distribution changes; see the chi-square test and its underlying chi-square distribution for a worked case that uses the same p-value mechanics on a different statistic.

How Do You Calculate a P-Value From a Z-Score or T-Statistic?

How to calculate p value comes down to three mechanical moves: compute the statistic, find the one-tail area, then adjust for the number of tails your test needs.

From a z-score. Compute z = (x̄ − μ₀) / (σ / √n), then look up the cumulative probability at that z in a standard normal table — the z-score article covers that standardization in more depth, and the z-table calculator returns the cumulative probability directly. Subtract the result from 1 to get the right-tail area, and double it for a two-tailed test.

From a t-statistic. Compute t = (x̄ − μ₀) / (s / √n) with df = n − 1, the same ratio the t-test article derives in full, including why the t-distribution’s heavier tails produce a larger p value than a z-test would give the same numeric statistic in a small sample. Look up the tail area for that t and df in a t-table, or let software do it (see below).

From other statistics. A chi-square statistic, an F statistic from ANOVA, or a rank-sum statistic from a nonparametric test all produce a p value the same way — the test statistic guide covers how degrees of freedom and table lookups generalize across these families.

A Worked Example: Two-Tailed Z-Test for a Filling Machine

A quality-control team wants to know whether the mean weight of cereal boxes leaving a filling machine differs from the target of 500 g — the same “is the process mean still on target” question NIST/SEMATECH’s handbook on comparisons to an assumed process mean walks through for one-sample tests. Historical process data give a known standard deviation of σ = 9 g. The team samples n = 36 boxes and measures a sample mean of x̄ = 503 g.

P-value decision process Four connected steps: state the hypotheses and set alpha; compute the standard error and z statistic; find the tail area and double it for the two-tailed p-value; compare p to alpha and decide. 1 State H₀, H₁, α H₀: μ = 500; H₁: μ ≠500; α = 0.05. 2 Compute SE and z SE = 9/√36 = 1.5; z =(503−500)/1.5 = 2.0. 3 Find the tail area P(Z>2.0) = 0.0228;two-tailed p = 0.0456. 4 Compare and decide p = 0.046 < α = 0.05 →reject H₀.
Figure 1. Four steps from the sample data to the reject/fail-to-reject decision for the filling-machine example.
  1. State the hypotheses and significance level.
H₀: μ = 500 g
H₁: μ ≠ 500 g   (two-tailed)
α = 0.05, chosen before collecting data

The team uses a two-tailed test because boxes that are too light or too heavy are both a problem.

  1. Compute the standard error and the test statistic.
SE = σ / √n = 9 / √36 = 9 / 6 = 1.5 g

z = (x̄ − μ₀) / SE = (503 − 500) / 1.5 = 3 / 1.5 = 2.0
  1. Find the p-value. The area to the right of z = 2.0 under the standard normal curve is 0.0228. Because the test is two-tailed, both tails count:
P(Z > 2.0) = 1 − 0.9772 = 0.0228

p = 2 × 0.0228 = 0.0456
  1. Compare p to α and decide.
p = 0.0456 < α = 0.05  →  reject H₀

The team concludes the mean fill weight is statistically significantly different from 500 g at the 5% level and flags the machine for inspection.

If the team only cared about boxes running heavy — a directional alternative, H₁: μ > 500 g — the test would be one-tailed instead, and only the right tail would count:

p = P(Z > 2.0) = 0.0228  ≈  0.023   (one-tailed, right)

That one-tailed p value is about half the two-tailed one, because it spends the whole α budget on a single direction instead of splitting it across both. Picking one tail after looking at the data would invalidate the test; the one-tailed vs. two-tailed guide covers how to commit to a tail in advance and when a directional H₁ is actually justified.

Try the Calculator

Enter z = 2.0, select Standard normal (z), and Two-sided below to reproduce this result. The same tool accepts a t-statistic and degrees of freedom if you are working a t-test instead.

Calculator

P Value Calculator

Enter values and compute the result.

For a one-sample t-test with a smaller sample, the mechanics are identical with a different distribution. Take n = 15 matched-pair differences with a sample mean difference of x̄ = 2.3 and sample standard deviation s = 4.1, testing against μ₀ = 0:

SE = s / √n = 4.1 / √15 = 1.059

t = (x̄ − μ₀) / SE = 2.3 / 1.059 = 2.173,  df = 14

two-tailed p ≈ 0.047

Because 0.047 is still below 0.05, this result also clears the conventional threshold. The t-distribution’s heavier tails do make a real difference, though: holding the statistic fixed at exactly 2.0 instead, a z-test gives a two-tailed p of 0.0455, while a t-test with df = 14 gives a two-tailed p of about 0.065 — noticeably larger for the identical numeric statistic, because the t-distribution puts more probability into its tails at low degrees of freedom.

How Do You Find a P-Value in Excel, Python, or R?

Software removes the table-lookup step, but you still need to compute the right statistic first.

Excel:   For a two-sample or paired comparison, =T.TEST(array1, array2, tails, type)
         returns the p-value directly. For a z-based one-sample test, compute z by
         hand, then use =NORM.S.DIST(z, TRUE) to get the cumulative probability and
         derive the tail area from it.

Python:  from scipy import stats
         stats.ttest_1samp(sample, popmean=mu0)   # returns (statistic, pvalue)
         stats.norm.sf(z)                         # one-tailed p from a z-statistic

R:       t.test(sample, mu = mu0)        # one-sample t-test, reports the p-value
         2 * pnorm(-abs(z))              # two-tailed p from a z-statistic

SciPy’s ttest_1samp reference documents the one-sample t-test function used above, and SciPy’s scipy.stats.norm reference documents the normal-distribution methods, including the survival function used for a one-tailed z p-value. Microsoft’s documentation for T.TEST and NORM.S.DIST covers the Excel syntax above, including the tails and type arguments that select one- vs. two-tailed and paired vs. independent designs.

How Do You Choose a Significance Level to Compare Against?

A p value only becomes a decision once you compare it to a pre-chosen significance level α — the maximum p value you are willing to treat as evidence against H₀. NIST/SEMATECH describes α as the risk you accept of rejecting a true null hypothesis, and that risk should be set before you see the data, not adjusted afterward to fit a result you want.

If p < α  →  reject H₀ (statistically significant at level α)
If p ≥ α  →  fail to reject H₀ (not enough evidence against H₀)

“Fail to reject” is not “prove true.” It only means the sample did not produce enough evidence to overturn the null hypothesis — the null hypothesis article covers why that asymmetry exists and why H₀ can never be “proven” by a test, only rejected or not rejected.

Common significance levels and where they are typically used
Significance level (α) Typical use
0.10 Early-stage or exploratory analysis, where a false positive is relatively cheap to follow up on and correct
0.05 The conventional default across most scientific and regulatory settings
0.01 A stricter threshold adopted when a false positive would be unusually costly to act on
≈3 × 10⁻⁷ (a "5σ" result) The discovery convention in particle physics, far beyond conventional significance

The international ICH E9 guideline on statistical principles for clinical trials — the standard regulators use to evaluate drug trials — states that “conventionally the probability of type I error is set at 5% or less,” which is the source of the 0.05 row above. At the opposite extreme, particle physicists require evidence equivalent to a five-standard-deviation (“5σ”) result before claiming a discovery, a convention discussed in Louis Lyons’ review of open statistical issues in particle physics; a one-tailed 5σ result corresponds to a p value of about 3 × 10⁻⁷, several orders of magnitude stricter than the 0.05 most fields use. The stricter the threshold, the more a field is weighting the cost of a false positive against the cost of missing a real effect — a trade-off the Type I and Type II errors guide and the statistical power article cover from the other side.

Common Mistakes When Interpreting a P-Value

  • Treating the p-value as the probability H₀ is true. The p value is computed assuming H₀, so it cannot also tell you the probability that assumption is correct. The American Statistical Association’s statement on statistical significance and p-values states this directly: “P-values do not measure the probability that the studied hypothesis is true, or the probability that the data were produced by random chance alone.” Getting that probability requires a prior and Bayes’ theorem, which the standard calculation never supplies.
  • Equating statistical significance with practical importance. A large enough sample can push p below 0.001 for an effect too small to matter in practice. Report an effect size — Cohen’s d, a correlation, an odds ratio — alongside the p value; the effect size guide covers how to compute and interpret the common ones.
  • Reading a non-significant result as proof of no effect. Failing to reject H₀ can mean the effect doesn’t exist, or it can mean your sample lacked the power to detect a real but smaller effect — a distinction the statistical power article walks through.
  • Letting a bigger sample size stand in for a bigger effect. Collecting more data shrinks the standard error and therefore the p value for almost any non-zero effect, which is exactly why sample sizes should be planned in advance rather than inflated until p drops below α.
  • Treating p = 0.05 as a hard pass/fail line. By the strict rule p < α, a p value of exactly 0.05 with α = 0.05 does not clear the threshold. The ASA statement’s principle on full reporting holds that “proper inference requires full reporting and transparency” — reporting the exact p value alongside the decision is more informative than collapsing it to “significant” or “not significant.”

Scientific conclusions and business or policy decisions should not be based only on whether a p-value passes a specific threshold.

American Statistical Association, Statement on Statistical Significance and P-Values (2016)

Statohub’s Take on P-Values

Statohub’s position is that a p value is a useful filter, not a verdict. Treat it as one input into a decision that should also include the effect size, the sample size, and whether the result replicates — never as a single number that settles the question on its own. The 0.05 convention is a shared language for comparing studies, not a law of nature, and the honest move is always to report the exact p value rather than just which side of α it landed on.

Put P-Values to Work With Statohub’s Tools

Computing a p value by hand is good practice; checking it quickly against a known case is what makes the number trustworthy day to day. Enter your z or t statistic above, open the full p-value calculator for a standalone version with the same options, or browse Statohub’s calculators for the related tools — the t-test calculator and the z-table calculator both feed directly into the formulas above. For the surrounding concepts, the Inferential Statistics hub covers hypothesis testing end to end, and which statistical test should I use helps you pick the right test before you ever compute a p value.

Sources

Sources

  1. NIST/SEMATECH e-Handbook of Statistical Methods — 7.1.3. What are statistical tests? NIST
  2. NIST/SEMATECH e-Handbook of Statistical Methods — 7.2.2. Are the data consistent with the assumed process mean? NIST
  3. NIST/SEMATECH e-Handbook of Statistical Methods — 1.3.6.7.1. Cumulative Distribution Function of the Standard Normal Distribution NIST
  4. NIST/SEMATECH e-Handbook of Statistical Methods — 1.3.6.7.2. Critical Values of the Student’s t-Distribution NIST
  5. American Statistical Association — Statement on Statistical Significance and P-Values (press release, 2016) American Statistical Association
  6. SciPy — scipy.stats.ttest_1samp reference SciPy
  7. SciPy — scipy.stats.norm reference SciPy
  8. Microsoft Support — T.TEST function Microsoft
  9. Microsoft Support — NORM.S.DIST function Microsoft
  10. OpenStax — 9.1 Null and Alternative Hypotheses, Introductory Statistics 2e OpenStax
  11. ICH E9 — Statistical Principles for Clinical Trials International Council for Harmonisation
  12. Lyons, L. — "Open Statistical Issues in Particle Physics," arXiv:0811.1663 arXiv

FAQ

Frequently asked questions

What Is P Value in Statistics?
A p value is the probability of observing a test result at least as extreme as yours, calculated under the assumption that the null hypothesis is true. It is not the probability that the null hypothesis is true, nor the probability of a mistake — it is a single conditional probability that measures how surprising your sample result is if nothing unusual is happening.
How Do You Calculate a P-Value by Hand?
Compute a standardized test statistic — z = (x̄ − μ₀)/(σ/√n) when σ is known, or t = (x̄ − μ₀)/(s/√n) with df = n − 1 when it is estimated — then look up the tail area beyond that statistic in a standard normal or Student’s t table. Double the one-tail area for a two-tailed test, or use it directly for a one-tailed test.
How Do You Find a P-Value From a Z-Score?
Look up the cumulative probability at your z-score in a standard normal table; for z = 2.0 that value is 0.9772. Subtract from 1 to get the right-tail area (0.0228), then multiply by 2 for a two-tailed test (0.0456), or use the one-tail value directly for a one-tailed test.
What Does a P-Value Less Than 0.05 Mean?
It means that if the null hypothesis were true, there would be less than a 5% chance of seeing data this extreme or more so by chance alone. Under the conventional α = 0.05 threshold, that is treated as sufficient evidence to reject the null hypothesis and call the result statistically significant — though the exact p value is more informative than the pass/fail label alone.
Can a P-Value Be Greater Than 1 or Negative?
No. A p value is a probability, so it must fall between 0 and 1 inclusive. A computed value outside that range always indicates an arithmetic or software error, never a valid result. The most common causes are doubling a value that a function already returned as two-tailed, swapping a cumulative distribution function for its complement by mistake, or feeding a negative variance into the formula. If your calculation ever produces a number outside 0 to 1, check those steps before trusting any other part of the result.
What Is the Difference Between a P-Value and a Confidence Interval?
A p value gives a single probability tied to one null hypothesis; a confidence interval gives a full range of plausible parameter values. The two agree in one useful way: if a 95% confidence interval excludes the null value, the corresponding two-tailed p value is below 0.05, and vice versa. Confidence intervals show direction and magnitude in a way a single p value cannot.