What Is a One-Sample Z-Test?
Three conditions identify this test. You have one sample, you are comparing its mean to a fixed reference value, and you know the population standard deviation from historical data, a regulatory standard, or a prior study. When σ is unknown, the correct test is the one-sample t-test, which substitutes the sample standard deviation s and uses the t-distribution.
The test was formalized within the frequentist framework developed by Ronald Fisher, Karl Pearson, and Jerzy Neyman during the early 20th century. The standard normal distribution it relies on is central to normal distribution theory and the Central Limit Theorem.
A one-sample z-test tests whether a sample mean equals a claimed population mean when the population standard deviation σ is known. The z statistic measures how many standard errors the sample mean falls from the null hypothesis value, and the p-value gives the probability of that distance occurring by chance.
When to Use a One-Sample Z-Test
Before running any test, you need to confirm the test fits your research question. The one-sample z-test is appropriate when all four of the following are true.
One sample, one mean
You have a single sample and you want to compare its mean to a fixed reference point — a regulatory standard, a manufacturer's claim, a historical population mean, or a known benchmark.
Population σ is known
The population standard deviation must come from a definitive external source — a prior census, a published study with a very large sample, a process specification, or historical production data.
Random, independent sample
The sample must be drawn randomly from the population. Each observation must be independent of the others. Violations here invalidate p-values and conclusions regardless of sample size.
Approximately normal sampling distribution
Either the population is normally distributed, or n ≥ 30. With n ≥ 30, the Central Limit Theorem guarantees that the sampling distribution of x̄ is approximately normal regardless of the population's shape.
Students frequently use a z-test when σ comes from their own sample. That is not a known σ — it is an estimate, and the correct test becomes a t-test. True known σ values come from regulatory databases, manufacturer specifications, or population-level studies with thousands of observations.
Decision Tree: Which Test Do You Need?
This decision tree walks through the most common scenarios. Start at the top and follow the path that matches your situation.
Statistical Test Selection Guide
Four Assumptions of the One-Sample Z-Test
Every statistical test carries assumptions. Violating them does not automatically invalidate a result, but it does mean your p-values may be inaccurate. Check all four before proceeding.
Known Population Standard Deviation
The population standard deviation σ must be a fixed, known quantity — not estimated from your data. Acceptable sources include national census data (for demographic research), historical process control data with thousands of prior measurements, a manufacturer's specification sheet, or a prior large-scale population study. If you only have your current sample's standard deviation s, the one-sample t-test is required.
Random Sampling
Each member of the population must have an equal probability of being selected. Convenience samples, voluntary response samples, and snowball samples all introduce selection bias that makes the p-value meaningless. If simple random sampling is not possible, stratified or cluster sampling can be used with appropriate adjustments.
Independence of Observations
Observations must not influence each other. This is violated when measurements are taken on the same subject repeatedly (use a paired test instead), when subjects are clustered (family members, students in the same class), or when measurements are autocorrelated over time (use time series methods). As a rough rule, if the sample is less than 10% of the population, independence is generally satisfied.
Approximate Normality of the Sampling Distribution
The sampling distribution of x̄ must be approximately normal. This is automatic when n ≥ 30 via the Central Limit Theorem, or when the underlying population is normally distributed at any sample size. With n < 30 and a non-normal population, the z-test is unreliable — the t-test with appropriate normality checks is preferred. Check for severe skewness or outliers using a Q-Q plot or the Shapiro-Wilk test.
The One-Sample Z-Test Formula
x̄ = sample mean
μ₀ = hypothesized population mean
σ = known population standard deviation
n = sample size
σ/√n = standard error (SE)
The formula measures how many standard errors the sample mean x̄ sits away from the null hypothesis value μ₀. The denominator σ/√n is the standard error of the mean — how much x̄ would vary across repeated samples of size n drawn from the population.
Null and Alternative Hypotheses
The null hypothesis always takes the equality form. The alternative hypothesis shape determines whether the test is one-tailed or two-tailed, which directly affects how the p-value is calculated. Choose the direction of H₁ based on your research question — before you look at the data.
| Test Type | Null Hypothesis (H₀) | Alternative Hypothesis (H₁) | p-value Calculation | Critical Values (α = 0.05) |
|---|---|---|---|---|
| Two-tailed | μ = μ₀ | μ ≠ μ₀ | 2 × P(Z > |z|) | ±1.96 |
| Right-tailed | μ = μ₀ | μ > μ₀ | P(Z > z) | +1.645 |
| Left-tailed | μ = μ₀ | μ < μ₀ | P(Z < z) | −1.645 |
Critical Values at Common Significance Levels
| Significance Level (α) | Two-Tailed z* | Right-Tailed z* | Left-Tailed z* |
|---|---|---|---|
| 0.10 | ±1.645 | +1.282 | −1.282 |
| 0.05 | ±1.960 | +1.645 | −1.645 |
| 0.01 | ±2.576 | +2.326 | −2.326 |
| 0.001 | ±3.291 | +3.090 | −3.090 |
How to Perform a One-Sample Z-Test: 5 Steps
State the hypotheses → Check assumptions → Obtain the z statistic → Review the p-value → Explain the conclusion
The SCORE Framework for One-Sample Z-Tests
One-Sample Z-Test Calculator
Enter your values below. The calculator computes the z statistic, standard error, two-tailed or one-tailed p-value, and renders a reject/fail-to-reject decision. For the one-sample t-test version (unknown σ), use the t-test calculator.
One-Sample Z-Test Calculator
Five Fully Solved One-Sample Z-Test Examples
Each example follows the SCORE framework and shows the complete arithmetic. These cover five different real-world contexts where the one-sample z-test appears most often.
Example 1 — Manufacturing Quality Control
A pharmaceutical company produces tablets with a labeled weight of 500 mg. Based on historical production data covering 10,000 batches, the population standard deviation is σ = 8 mg. A quality inspector randomly samples n = 36 tablets from a new batch and measures a sample mean of x̄ = 503.5 mg. At α = 0.05, does this batch deviate from specification?
Hypotheses: H₀: μ = 500 mg | H₁: μ ≠ 500 mg (two-tailed — any deviation from spec is a concern)
Assumptions met: σ = 8 known from historical records ✓ | Random sample ✓ | n = 36 ≥ 30 → CLT applies ✓ | Critical value for α = 0.05, two-tailed: z* = ±1.960
Z statistic:
SE = σ/√n = 8/√36 = 8/6 = 1.333
z = (503.5 − 500) / 1.333 = 3.5 / 1.333 = 2.625
p-value: P(Z > 2.625) ≈ 0.0043 (one tail). Two-tailed p = 2 × 0.0043 = p ≈ 0.0087
Since |z| = 2.625 > z* = 1.960 and p = 0.0087 < α = 0.05 → Reject H₀
APA Report: A one-sample z-test showed that the new batch mean (M = 503.5 mg, σ = 8) differed significantly from the specification of 500 mg, z(36) = 2.63, p = .009. The batch fails the quality check at α = 0.05.
✅ Conclusion: At α = 0.05, there is sufficient statistical evidence that this batch deviates from the labeled specification. The quality team should investigate the production process.
Example 2 — Public Health Research
The national benchmark for adult systolic blood pressure is μ₀ = 120 mmHg with a known population SD of σ = 15 mmHg. A researcher samples n = 50 adults in a high-altitude city and finds x̄ = 124.3 mmHg. Is there evidence that the city's mean blood pressure differs from the national benchmark? Test at α = 0.01.
Hypotheses: H₀: μ = 120 mmHg | H₁: μ ≠ 120 mmHg (two-tailed)
Assumptions met: σ = 15 known from national data ✓ | n = 50 ≥ 30 ✓ | Critical value: z* = ±2.576 (α = 0.01, two-tailed)
Z statistic:
SE = 15/√50 = 15/7.071 = 2.121
z = (124.3 − 120) / 2.121 = 4.3 / 2.121 = 2.028
p-value: Two-tailed p = 2 × P(Z > 2.028) = 2 × 0.0213 = p ≈ 0.043
Since p = 0.043 > α = 0.01 → Fail to Reject H₀ at this stricter threshold
Note: The same result is significant at α = 0.05 but not at α = 0.01. This illustrates why the significance level must be chosen before data collection.
❌ Conclusion at α = 0.01: Insufficient evidence to conclude the city mean differs from 120 mmHg. At α = 0.05, the conclusion reverses — demonstrating how the choice of α changes decisions.
Example 3 — Education Assessment (One-Tailed)
A school district implements a new reading program. Based on statewide testing across millions of students, the known population mean is μ₀ = 72 points and σ = 10 points. After one semester, a random sample of n = 64 students scores x̄ = 74.8. Is there evidence the program raises scores above the state mean? Test at α = 0.05.
Hypotheses: H₀: μ = 72 | H₁: μ > 72 (right-tailed — we're specifically testing for improvement)
Assumptions met: σ = 10 known from statewide data ✓ | n = 64 ≥ 30 ✓ | Critical value for right-tailed α = 0.05: z* = +1.645
Z statistic:
SE = 10/√64 = 10/8 = 1.25
z = (74.8 − 72) / 1.25 = 2.8 / 1.25 = 2.24
p-value (right-tailed): P(Z > 2.24) = 1 − 0.9875 = p ≈ 0.0125
Since z = 2.24 > z* = 1.645 and p = 0.0125 < 0.05 → Reject H₀
APA Report: A one-tailed one-sample z-test provided significant evidence that the program raised mean scores above the state average, z(64) = 2.24, p = .013.
✅ Conclusion: The reading program produced a statistically significant improvement. The sample mean of 74.8 is 2.8 points above the state mean, and this difference is unlikely to reflect sampling error at α = 0.05.
Example 4 — Customer Satisfaction Survey
An e-commerce company's industry benchmark shows average order processing time is μ₀ = 48 hours with σ = 12 hours. The company's operations team samples n = 100 recent orders and finds x̄ = 45.6 hours. Has the company improved below the industry average? Test at α = 0.05 (left-tailed).
Hypotheses: H₀: μ = 48 hours | H₁: μ < 48 hours (left-tailed — testing whether they are faster)
Assumptions met: σ = 12 from industry database ✓ | n = 100 ≥ 30 ✓ | Critical value: z* = −1.645
Z statistic:
SE = 12/√100 = 12/10 = 1.20
z = (45.6 − 48) / 1.20 = −2.4 / 1.20 = −2.00
p-value (left-tailed): P(Z < −2.00) = p ≈ 0.0228
Since z = −2.00 < z* = −1.645 and p = 0.0228 < 0.05 → Reject H₀
APA Report: A one-tailed one-sample z-test confirmed that mean order processing time (M = 45.6 h, σ = 12) was significantly below the industry benchmark of 48 hours, z(100) = −2.00, p = .023.
✅ Conclusion: The company's processing time is statistically faster than the industry standard. The 2.4-hour difference is unlikely due to sampling variability.
Example 5 — Environmental Science
Environmental regulations set the maximum mean lead concentration in drinking water at μ₀ = 15 ppb. From years of monitoring across thousands of sites, σ = 4 ppb. A regulator tests n = 25 samples from a new source and finds x̄ = 16.8 ppb. Test whether the concentration exceeds the limit. α = 0.05 (right-tailed). Note: n = 25 < 30, but lead concentration data is approximately normally distributed from prior studies.
Hypotheses: H₀: μ = 15 ppb | H₁: μ > 15 ppb (right-tailed)
Assumptions: σ = 4 known ✓ | n = 25 < 30, but population is approximately normal from prior studies ✓ | Critical value z* = +1.645
Z statistic:
SE = 4/√25 = 4/5 = 0.80
z = (16.8 − 15) / 0.80 = 1.8 / 0.80 = 2.25
p-value (right-tailed): P(Z > 2.25) = p ≈ 0.0122
Since p = 0.0122 < 0.05 → Reject H₀
APA Report: Lead concentration (M = 16.8 ppb, σ = 4) significantly exceeded the regulatory limit of 15 ppb, z(25) = 2.25, p = .012. Regulatory action is warranted.
✅ Conclusion: Statistical evidence supports elevated lead levels above the threshold. This illustrates a case where n < 30 is acceptable because the normal population assumption is justified by prior evidence.
Running the Test in R, Python, and Excel
Manual calculation is essential for understanding the logic. In practice, most analysts run z-tests in statistical software. The code below uses the data from Example 1 (pharmaceutical tablets: x̄ = 503.5, μ₀ = 500, σ = 8, n = 36).
One-Sample Z-Test in R
Base R does not have a built-in one-sample z-test function (it assumes σ is unknown for the t-test). The BSDA package provides z.test(), or you can compute it directly.
# Method 1: Manual calculation in R x_bar <- 503.5 # sample mean mu_0 <- 500 # null hypothesis mean sigma <- 8 # known population SD n <- 36 # sample size SE <- sigma / sqrt(n) z <- (x_bar - mu_0) / SE # Two-tailed p-value p <- 2 * pnorm(-abs(z)) cat("SE =", round(SE, 4), "\n") cat("z =", round(z, 4), "\n") cat("p =", round(p, 4), "\n") # Method 2: Using BSDA package # install.packages("BSDA") library(BSDA) x <- c(503.5) # or your full data vector z.test(x, mu = 500, sigma.x = 8, alternative = "two.sided") # Confidence interval (95%) ci_lower <- x_bar - 1.96 * SE ci_upper <- x_bar + 1.96 * SE cat("95% CI: [", round(ci_lower, 3), ",", round(ci_upper, 3), "]")
One-Sample Z-Test in Python (SciPy)
The statsmodels library provides ztest(). Alternatively, you can compute the z statistic using SciPy's normal distribution.
import numpy as np from scipy import stats from statsmodels.stats.weightstats import ztest # Sample data (or use summary statistics directly) x_bar = 503.5 mu_0 = 500 sigma = 8 n = 36 # Manual calculation SE = sigma / np.sqrt(n) z = (x_bar - mu_0) / SE p = 2 * (1 - stats.norm.cdf(abs(z))) print(f"SE = {SE:.4f}") print(f"z = {z:.4f}") print(f"p = {p:.4f}") # 95% confidence interval ci_lower = x_bar - stats.norm.ppf(0.975) * SE ci_upper = x_bar + stats.norm.ppf(0.975) * SE print(f"95% CI: [{ci_lower:.3f}, {ci_upper:.3f}]") # Effect size (Cohen's d) cohens_d = abs(x_bar - mu_0) / sigma print(f"Cohen's d = {cohens_d:.4f}")
One-Sample Z-Test in Excel
Excel includes NORM.S.DIST() and Z.TEST() functions for this test.
=== Cell Setup === A1: Sample Mean (x̄) B1: 503.5 A2: Null Mean (μ₀) B2: 500 A3: Population SD (σ) B3: 8 A4: Sample Size (n) B4: 36 A5: Alpha B5: 0.05 === Formulas === # Standard Error A7: SE B7: =B3/SQRT(B4) # Z Statistic A8: z B8: =(B1-B2)/B7 # Two-tailed p-value A9: p-value (two-tailed) B9: =2*(1-NORM.S.DIST(ABS(B8),TRUE)) # One-tailed p-value (right) A10: p-value (right-tail) B10: =1-NORM.S.DIST(B8,TRUE) # Critical value at α = 0.05 A11: Critical z (two-tail) B11: =NORM.S.INV(1-B5/2) # Z.TEST function (returns one-tailed p for right-tail) # Paste your data in column D first A12: Z.TEST result B12: =Z.TEST(D2:D37, B2, B3) # Multiply by 2 for two-tailed
One-Sample Z-Test vs One-Sample T-Test
The z-test and t-test address the same research question but under different conditions. The t-test is far more common in practice because the population σ is almost never truly known.
| Feature | One-Sample Z-Test | One-Sample T-Test |
|---|---|---|
| Population SD (σ) | Known — required | Unknown — estimated by s |
| Test statistic | z = (x̄ − μ₀) / (σ/√n) | t = (x̄ − μ₀) / (s/√n) |
| Distribution used | Standard normal Z ~ N(0,1) | t-distribution with df = n−1 |
| Sample size requirement | n ≥ 30 or normal population | Any size (with normality check) |
| Tail heaviness | Standard normal tails | Heavier tails (reflects σ uncertainty) |
| Critical value at α = 0.05 (two-tailed) | z* = ±1.960 | t* depends on df (larger for small n) |
| How common in practice? | Less common (σ rarely known) | More common (σ usually unknown) |
| When identical? | As n → ∞, t-distribution → standard normal, so results converge | |
Industrial quality control (where process σ is established from years of data), large-scale public health benchmarking against national databases, and psychometric testing where test instruments have published normative σ values. In all other cases, reach for the one-sample t-test.
How to Interpret the p-Value and Decision
The p-value has a single precise definition: it is the probability of observing a test statistic as extreme as yours (or more extreme), given that the null hypothesis is true. It does not measure the probability that H₀ is true, the probability that the result occurred by chance, or the size of the effect.
| p-value Range | Decision | Plain Language | What It Does NOT Mean |
|---|---|---|---|
| p < α | Reject H₀ | Evidence against the null is strong enough at level α | H₀ is proven false; the effect is large; the result is practically important |
| p ≥ α | Fail to Reject H₀ | Evidence against H₀ is insufficient at level α | "Accept H₀"; H₀ is true; the effect is zero |
| p = 0.049 | Reject at α = 0.05 | Marginally significant — context matters | More significant than p = 0.001 |
Confidence Interval from a One-Sample Z-Test
Every z-test has an equivalent confidence interval. The two-tailed 95% CI for the population mean is:
A confidence interval and a hypothesis test give consistent conclusions: if μ₀ falls outside the 95% CI, the two-tailed test at α = 0.05 will reject H₀. For Example 1 (pharmaceutical tablets): CI = 503.5 ± 1.96 × 1.333 = [500.89, 506.11]. Since μ₀ = 500 falls outside this interval, rejection of H₀ is confirmed.
Effect Size: Cohen's d for the One-Sample Z-Test
Statistical significance depends on sample size — with a large enough n, even a trivially small difference becomes significant. Effect size measures the practical magnitude of the difference, independent of sample size. For the one-sample z-test, the standard effect size is Cohen's d.
d < 0.2 = negligible
d ≈ 0.2 = small
d ≈ 0.5 = medium
d ≈ 0.8 = large
For Example 1: d = (503.5 − 500)/8 = 0.4375 — a small-to-medium effect. Even with a significant p-value of 0.009, the actual deviation from specification (3.5 mg) may or may not warrant production changes depending on tolerance thresholds. Always report both p and d. See the full guide to effect size in hypothesis testing.
How to Report a One-Sample Z-Test in APA Format
APA 7th edition reporting for a one-sample z-test follows a consistent template. The reader needs the test name, sample mean, population σ, z statistic, sample size (or degrees of freedom), p-value, and effect size.
Write p with a lowercase italicized p. Drop the leading zero for p values (write p = .009, not p = 0.009). Write z in italics. Report exact p-values rather than inequalities (p = .027, not p < .05) unless p < .001.
7 Common Mistakes in One-Sample Z-Tests
| Mistake | What Goes Wrong | Correct Approach |
|---|---|---|
| Using sample s as if it were known σ | Invalid test statistic; p-values too small | Use one-sample t-test when σ is estimated |
| Choosing H₁ direction after seeing the data | Inflated Type I error rate (p-hacking) | State H₁ before data collection |
| Writing "accept H₀" when p ≥ α | Misrepresents what failing to reject means | Write "fail to reject H₀" or "insufficient evidence" |
| Ignoring effect size | Significant p with trivial practical difference | Report Cohen's d alongside the p-value |
| Using a two-tailed test when direction was pre-specified | Lower statistical power; may miss a true effect | Use a one-tailed test if direction is justified before data collection |
| Applying z-test with n < 30 and non-normal population | Sampling distribution may not be normal | Verify normality assumption or use t-test |
| Treating p-value as probability H₀ is true | Fundamental misinterpretation of frequentist inference | p is probability of data given H₀ is true, not P(H₀ is true | data) |
Where the One-Sample Z-Test Appears in Practice
Manufacturing QC
Testing whether a production batch's mean weight, volume, or purity meets specification limits when historical process σ is established.
Clinical Research
Comparing a study sample's mean biomarker level to a published population norm when large prior studies define σ precisely.
Education Testing
Comparing a school or district's mean score to a statewide or national benchmark where population σ is published by the testing authority.
Environmental Monitoring
Testing whether pollutant concentrations exceed regulatory thresholds when historical baseline σ is established from extensive monitoring records.
Business Analytics
Evaluating whether a process metric (delivery time, defect rate, load time) has shifted from a known historical mean with documented σ.
Psychometrics
Comparing a clinical sample's mean test score to a normative population mean when the instrument's normative σ is published by test developers.
Entity and Formula Glossary
| Term | Symbol | Definition |
|---|---|---|
| Sample Mean | x̄ | The arithmetic average of all values in the sample. The point estimate of the population mean. |
| Null Hypothesis | H₀ | The default claim being tested. For the one-sample z-test: H₀: μ = μ₀. Rejected only when p < α. |
| Alternative Hypothesis | H₁ | The claim supported when H₀ is rejected. Can be two-tailed (≠), right-tailed (>), or left-tailed (<). |
| Population Mean | μ | The true mean of the entire population. The quantity being estimated and tested in a z-test. |
| Hypothesized Mean | μ₀ | The specific value of μ stated in the null hypothesis. Also called the null value or reference value. |
| Population Standard Deviation | σ | The known spread of the population. Must come from external data — not from the current sample. |
| Standard Error | SE = σ/√n | The standard deviation of the sampling distribution of x̄. Decreases as n increases. |
| Z Statistic | z | The test statistic: z = (x̄ − μ₀)/SE. Measures distance from null in standard error units. |
| Critical Value | z* | The z value that marks the boundary of the rejection region. Depends on α and the tail type. |
| p-value | p | Probability of observing a test statistic as extreme as z (or more), given H₀ is true. If p < α, reject H₀. |
| Significance Level | α | The threshold for p-values. Common values: 0.05, 0.01, 0.10. Set before data collection. |
| Type I Error | α | Rejecting a true null hypothesis. The probability of a Type I error equals α. |
| Type II Error | β | Failing to reject a false null hypothesis. Probability = β; statistical power = 1 − β. |
| Cohen's d | d = (x̄ − μ₀)/σ | Standardized effect size. Small ≈ 0.2, medium ≈ 0.5, large ≈ 0.8. Reports practical significance. |
| Confidence Interval | x̄ ± z* × SE | A range of plausible values for μ. A 95% CI excludes μ₀ exactly when the two-tailed test at α = 0.05 rejects H₀. |
| Central Limit Theorem | CLT | For n ≥ 30, the sampling distribution of x̄ is approximately normal regardless of population shape. |