Skip to main content
v2026.11,986 entries · CC-BY 4.0

Z Statistic to P Value: Formulas, Tests, and Code

Learn how to convert a z statistic to p value for one- and two-tailed tests, with exact formulas, worked arithmetic, APA reporting rules, and code snippets.

Written and maintained by CASRAI Editorial Board

Published

On this page

Definition in One Paragraph

Converting a z statistic to p value is the mathematical procedure of translating a standardized test score from a standard normal distribution into a tail probability under the assumption that the null hypothesis is true. In frequentist hypothesis testing, a z-statistic measures how many standard errors an observed sample metric—such as a mean or proportion—diverges from the hypothesized null value. The resulting p-value quantifies the probability of obtaining a test statistic at least as extreme as the observed score purely through random sampling variability. Researchers compare this probability against a chosen significance threshold (typically α = .05, .01, or .001) to decide whether data warrant rejecting the null hypothesis.

Formula with Every Symbol Explained

Converting a standardized z-statistic into an inferential p-value relies on the cumulative distribution function (CDF) of the standard normal distribution, denoted by Phi (Φ). For any real value z, the cumulative probability is defined by the integral:

Φ(z) = P(Z ≤ z) = ∫-∞z (1 / √(2π)) × e–t2 / 2 dt

Every symbol in this relationship represents a distinct parameter:

  • z: Standardized test statistic: z = (x̄ – μ0) / SE for means, or z = (p̂ – p0) / SE for proportions.
  • Φ(z): Cumulative distribution function of N(0, 1), measuring total probability from -∞ up to z.
  • Z: Standard normal random variable (mean μ = 0, standard deviation σ = 1).
  • π: Archimedes’ constant (≈ 3.14159).
  • e: Base of natural logarithms (≈ 2.71828).
  • t: Dummy integration variable along the standardized score axis.

The exact formula used to determine the p-value depends on the alternative hypothesis (Ha):

Two-Tailed Hypothesis Test

For non-directional tests (H0: θ = θ0 vs. Ha: θ ≠ θ0), deviations in either tail count against the null. By bilateral normal symmetry, the two-tailed p-value doubles the upper tail area:

p = 2 × [1 – Φ(|z|)] = 2 × Φ(-|z|)

Right-Tailed (Upper-Tail) Hypothesis Test

For directional upper tests (H0: θ ≤ θ0 vs. Ha: θ > θ0), only positive deviations provide evidence. The p-value is the upper survival probability:

p = P(Z ≥ z) = 1 – Φ(z)

Left-Tailed (Lower-Tail) Hypothesis Test

For directional lower tests (H0: θ ≥ θ0 vs. Ha: θ < θ0), negative deviations provide evidence. The p-value equals the cumulative probability directly:

p = P(Z ≤ z) = Φ(z)

Worked Example with Arithmetic

Consider a laboratory audit evaluating an automated pipetting workstation. Target dispense volume is μ0 = 50.0 μL with a known historical standard deviation of σ = 1.2 μL.

An audit team draws an independent sample of n = 36 cycles, yielding sample mean x̄ = 50.45 μL. The team performs a two-tailed statistical test at α = .05 (H0: μ = 50.0 μL vs. Ha: μ ≠ 50.0 μL):

Step 1: Calculate Standard Error

SE = σ / √n = 1.2 / √36 = 1.2 / 6 = 0.20 μL

Step 2: Calculate the Z-Statistic

z = (x̄ – μ0) / SE = (50.45 – 50.00) / 0.20 = 0.45 / 0.20 = 2.25

Step 3: Convert Z-Statistic to P-Value

Using a standard normal z-table lookup, the cumulative probability for z = 2.25 is Φ(2.25) = 0.9878. The upper tail area is 1 – 0.9878 = 0.0122. For a two-tailed test:

p = 2 × [1 – Φ(|2.25|)] = 2 × 0.0122 = 0.0244

Step 4: Formal Statistical Decision

Because p = .0244 ≤ .05, the result falls in the rejection region. The auditors reject H0 at α = .05, concluding that dispense volume differs significantly from 50.0 μL.

Interpretation and Reading Guidance

Following the frequentist definition of a p-value, p = .024 indicates a 2.44% chance of observing a mean deviating by ≥ 0.45 μL in either direction if H0 were true. It does not measure the probability that H0 is true, nor effect magnitude. National Institute of Standards and Technology (NIST) benchmarks provide interpretation guidelines:

P-Value Range (p) Test Statistic Range (|z|) Strength of Evidence NIST Decision Action (at α = .05)
p < .001 |z| ≥ 3.29 Overwhelming evidence against H0 Reject H0; highly statistically significant
.001 ≤ p < .01 2.58 ≤ |z| < 3.29 Strong evidence against H0 Reject H0; significant at α = .01 and α = .05
.01 ≤ p < .05 1.96 ≤ |z| < 2.58 Moderate evidence against H0 Reject H0; significant at standard α = .05
.05 ≤ p < .10 1.645 ≤ |z| < 1.96 Weak or marginal evidence against H0 Fail to reject H0 at α = .05
p ≥ .10 |z| < 1.645 Inconclusive or no evidence against H0 Fail to reject H0; retain null baseline

Assumptions and Common Mistakes

Valid conversion of a z-statistic to an inferential p-value requires satisfying three core assumptions:

  1. Known Population Variance (σ): The population standard deviation must be known. If σ is estimated by sample standard deviation s in small samples, researchers must apply Student’s t-distribution vs normal distribution models to prevent anti-conservative bias.
  2. Normality or Large Sample Size: The population must be approximately normal, or sample size must be sufficiently large (n ≥ 30) for the Central Limit Theorem to ensure sampling distribution normality.
  3. Independent Sampling: Observations must be sampled independently at random.

Common analytical mistakes to avoid:

  • Omitting Two-Tailed Doubling: Reporting a single-tail probability for a two-tailed test halves the reported p-value and inflates Type I errors.
  • Sign Reversal with Negative Z-Scores: For a negative score (z = -2.15) in a right-tailed test, reporting cumulative lower tail Φ(-2.15) = .0158 rather than survival area 1 – Φ(-2.15) = .9842 inverts the conclusion.
  • Confusing Significance with Effect Magnitude: Large samples can yield tiny p-values (p < .001) for negligible practical deviations; always report effect sizes alongside confidence intervals.
  • Post-Hoc Directionality Switching: Selecting a one-tailed test after inspecting data direction constitutes p-hacking; directionality must be preregistered.

How to Report It (APA Example)

The Publication Manual of the American Psychological Association (APA 7th Edition, Section 6.43–6.44) outlines strict standards for reporting statistical tests:

  • Italicization: Italicize Latin statistical symbols (z, p, n). Do not italicize Greek letters (α, β, μ) or numbers.
  • Spacing: Insert spaces around mathematical operators (=, <, >).
  • Decimal Precision: Report z-scores to two decimal places (e.g., z = 2.25) and exact p-values to two or three decimal places (e.g., p = .024).
  • Leading Zeros: Omit leading zeros before p-values because probabilities cannot exceed 1.0 (write p = .024, never p = 0.024). Retain leading zeros for z-scores (write z = 0.85).
  • Truncation Threshold: Never write p = .000; report values under .001 as p < .001.

Standard reporting models include:

  • Narrative format: “A one-sample z-test indicated that the mean dispense volume was significantly greater than specification, z = 2.25, p = .024, 95% CI [50.06, 50.84].”
  • Parenthetical format: “The laboratory audit revealed a statistically significant calibration drift (*z* = 2.25, *p* = .024).”
  • Non-significant outcome: “Dispense volume did not deviate significantly from baseline (*z* = 1.15, *p* = .250).”
  • High significance: “Automated calibration adjustments substantially reduced cycle variance (*z* = 3.82, *p* < .001).”

How to Calculate It in Excel, R, or Python

Modern analytical software computes exact cumulative probabilities without printed tables.

1. Microsoft Excel

In Microsoft Excel, NORM.S.DIST evaluates the standard normal distribution. Setting cumulative to TRUE returns Φ(z). For further details, consult our reference guide on the standard normal distribution in Excel.

# Two-tailed p-value from z in cell A1:
=2 * (1 - NORM.S.DIST(ABS(A1), TRUE))

# Right-tailed (upper-tail) p-value:
=1 - NORM.S.DIST(A1, TRUE)

# Left-tailed (lower-tail) p-value:
=NORM.S.DIST(A1, TRUE)

2. R Language

In R, pnorm() computes standard normal cumulative probabilities. Using abs() handles two-tailed symmetry, while lower.tail = FALSE evaluates upper survival tails directly:

z <- 2.25

# Two-tailed p-value
p_two_tailed <- 2 * pnorm(abs(z), lower.tail = FALSE)

# Right-tailed p-value (upper tail)
p_right_tailed <- pnorm(z, lower.tail = FALSE)

# Left-tailed p-value (lower tail)
p_left_tailed <- pnorm(z, lower.tail = TRUE)

cat(sprintf("Two-tailed p-value: %.4fn", p_two_tailed))
# Output: Two-tailed p-value: 0.0244

3. Python (SciPy)

In Python, scipy.stats.norm provides cumulative distribution (cdf) and survival functions (sf):

import scipy.stats as stats

z = 2.25

# Two-tailed p-value
p_two_tailed = 2 * stats.norm.sf(abs(z))

# Right-tailed p-value
p_right_tailed = stats.norm.sf(z)

# Left-tailed p-value
p_left_tailed = stats.norm.cdf(z)

print(f"Two-tailed p-value: {p_two_tailed:.4f}")
# Output: Two-tailed p-value: 0.0244

Frequently Asked Questions (FAQ)

What is the difference between a z-statistic and a p-value?

A z-statistic measures the number of standard errors an observed sample metric deviates from the null mean. A p-value is the probability of observing a score that extreme assuming the null is true. The z-statistic is an intermediate test calculation; the p-value is the decision metric evaluated against alpha.

How do you convert a negative z-statistic to a p-value?

For two-tailed tests, apply absolute value: p = 2 × [1 – Φ(|z|)]. By normal curve symmetry, z = -2.25 yields the same two-tailed p-value (p = .0244) as z = +2.25. For left-tailed tests, evaluate p = Φ(z); for right-tailed tests, compute p = 1 – Φ(z).

Why do you multiply by 2 for a two-tailed p-value?

Two-tailed alternative hypotheses test deviations in either direction (larger or smaller than baseline). Because extreme outcomes in both directions contradict the null hypothesis, the total rejection probability must include both symmetric tails.

Can a p-value ever equal zero?

Under a continuous normal distribution, a p-value never equals zero because normal curve tails extend asymptotically to infinity. Software output displaying p = 0.000 reflects decimal truncation; report such results as p < .001 in manuscripts.

What critical z-score corresponds to a p-value of .05?

For two-tailed tests at α = .05, the critical thresholds are z = ±1.96 (2.5% per tail). For one-tailed tests at α = .05, the critical cutoff is z = 1.645 (upper tail) or z = -1.645 (lower tail), placing the full 5% rejection region in one tail.

Sources

Follow CASRAI

Research-administration guidance, standards updates and independent tool reviews.

Ask CASRAI · free to try

Ask about Z Statistic to P Value: Formulas, Tests, and Code

Ask your first 2 questions free below. Subscribers get 150 a day for $29 a month.

An AI assistant specialized in research administration. It cites the sources behind every answer, labels web answers and says when it can't answer.

Answers draw on CASRAI's guides and dictionary plus the federal and funder documents we index: Federal Register, Grants.gov, Regulations.gov and UKRI.

Works on this site and inside Claude, Cursor and the AI tools you already use.

Everything CASRAI publishes — this page, the dictionary, the guides and the news — stays free to read, with no account and no card.

Referenced across the research world

University of Cambridge logoColumbia University logoCrossref logoUniversity of Edinburgh logoHarvard University logoUniversity of Oxford logoPrinceton University logoStanford School of Medicine logoUniversity College London logoORCID logoUniversity of Cambridge logoColumbia University logoCrossref logoUniversity of Edinburgh logoHarvard University logoUniversity of Oxford logoPrinceton University logoStanford School of Medicine logoUniversity College London logoORCID logo
  • University of Cambridge logo
  • Columbia University logo
  • Crossref logo
  • University of Edinburgh logo
  • Harvard University logo
  • University of Oxford logo
  • Princeton University logo
  • Stanford School of Medicine logo
  • University College London logo
  • ORCID logo

View CASRAI adoption →