What is a One-Sample Z-Test Calculator?
A one-sample z-test checks whether a population mean equals a hypothesized value μ₀ when the population standard deviation σ is known. The z test formula is z = (x̄ − μ₀) / (σ / √n): the gap between the sample mean and μ₀, measured in standard errors. The p-value comes from the standard normal curve, and you reject H₀ when p ≤ α. Example: x̄ = 498.6 g, μ₀ = 500 g, σ = 4 g and n = 40 give z = −2.21 and a two-tailed p = 0.027, so H₀ is rejected at α = 0.05.
What the One-Sample Z-Test Calculator does
This free one sample z test calculator takes the sample mean (or the raw values), the known population standard deviation σ, the sample size n and μ₀, and returns the z statistic, p-value, critical value and a reject or fail-to-reject decision for a two-tailed, left-tailed or right-tailed test. It also gives a 95% confidence interval for μ, the effect size (x̄ − μ₀) / σ, a standard normal curve with the rejection region shaded and the full step-by-step working with your numbers.
If you only need the number, it also works as a z test statistic calculator: z is shown first, with the critical value beside it. A one-sample z-test (also called a single sample z test or 1 sample z test) requires a known population standard deviation, taken from outside the sample: a filling machine whose variability has been tracked for years, a standardized test scaled to a fixed SD, or an instrument with a documented precision. When σ has to be estimated from the same sample, the t distribution is the correct reference, so use the One-Sample t-Test Calculator. To compare two means, use the Two-Sample Z-Test Calculator; for a yes/no outcome, use the One Proportion Z-Test Calculator.
How to use the One-Sample Z-Test Calculator
- Choose the alternative hypothesis: two-tailed (≠) unless you predicted a direction before collecting the data, otherwise left-tailed (<) or right-tailed (>).
- Enter the hypothesized mean μ₀, the known population standard deviation σ and the significance level α, usually 0.05.
- Enter the sample mean x̄ and sample size n, or switch to Raw data and paste the observations (commas, spaces or one per line, straight from Excel or Google Sheets).
- Read z, the p-value and the decision, then open the step-by-step solution for the standard error, the z calculation, the critical value and the confidence interval.
What is a one-sample z-test?
A one-sample z-test compares the mean of one sample with a fixed reference value μ₀. The null hypothesis is H₀: μ = μ₀; the alternative is μ ≠ μ₀ (two-tailed), μ < μ₀ (left-tailed) or μ > μ₀ (right-tailed). When H₀ is true and σ is known, the z statistic follows the standard normal distribution, so its p-value and critical values come straight from the z table.
The one-sample z-test requires a known population standard deviation. That is the single difference from the one-sample t-test, which estimates the spread with the sample standard deviation s and uses the t distribution with n − 1 degrees of freedom. Using s in place of σ with a small sample makes the z-test reject H₀ too often.
How to calculate a one-sample z-test by hand
To find the test statistic z and finish the test, follow the same steps the calculator shows:
- State the hypotheses: H₀: μ = μ₀ and H₁: μ ≠ μ₀, μ < μ₀ or μ > μ₀.
- Choose the significance level α, usually 0.05.
- Find the sample mean x̄ (x̄ = Σx / n if you have raw data) and note n and the known σ.
- Compute the standard error of the mean: SE = σ / √n.
- Calculate the test statistic: z = (x̄ − μ₀) / SE.
- Convert z to a p-value with the standard normal curve (the P-Value from Z Calculator does this), or compare z with the critical value for your α and tail.
- Decide: reject H₀ if p ≤ α, which is the same as z falling in the rejection region; otherwise fail to reject H₀.
One-sample z-test formula
The z test statistic formula for one sample divides the distance between the sample mean and the hypothesized mean by the standard error of the mean, which uses the known population standard deviation.
| Symbol | Meaning |
|---|---|
| x̄ | sample mean |
| μ₀ | hypothesized population mean from H₀ |
| σ | known population standard deviation |
| n | sample size |
| Z | a standard normal random variable |
This is different from the z-score of a single value, z = (x − μ) / σ, which the Z-Score Calculator finds. For a sample mean the spread shrinks to σ / √n, so the same gap gives a much larger z.
One-sample z-test example
Worked example 1: cereal box filling (summary data)
Problem. A filling line has a long-run σ of 4 g. A sample of n = 40 boxes labelled 500 g averages x̄ = 498.6 g. Test H₀: μ = 500 against H₁: μ ≠ 500 at α = 0.05. These are the calculator’s default inputs (the Cereal boxes example).
- 01Standard error: SE = 4 / √40 = 0.6325.
- 02z = (498.6 − 500) / 0.6325 = −2.2136.
- 03Two-tailed p-value = 2 · P(Z ≥ 2.2136) ≈ 0.0269.
- 04Critical values: ±1.96. Since |z| = 2.21 > 1.96, z falls in the rejection region.
- 0595% CI for μ: 498.6 ± 1.96 × 0.6325 = (497.3604, 499.8396).
Answer. Reject H₀ (p ≈ 0.027 < 0.05). The line is under-filling by about 1.4 g on average; the confidence interval lies entirely below 500 g. The effect size is (498.6 − 500) / 4 = −0.35 standard deviations.
Worked example 2: one-sample z-test from raw data
The same line is checked again with 12 boxes: 497, 502, 495, 499, 501, 494, 498, 496, 503, 497, 499, 495 g. Click the Raw data example above the calculator to load them. σ is still 4 g. Test H₀: μ = 500 against H₁: μ ≠ 500 at α = 0.05.
- Sample mean: x̄ = 5,976 / 12 = 498.
- Standard error: SE = 4 / √12 = 1.1547.
- z = (498 − 500) / 1.1547 = −1.7321.
- Two-tailed p = 2 · P(Z ≥ 1.7321) = 0.0833, which is above 0.05, and |z| = 1.73 is inside ±1.96.
- Fail to reject H₀. The 95% CI for μ is (495.7368, 500.2632), which still contains 500. With only 12 boxes the 2 g shortfall is not distinguishable from chance; the 40-box sample in example 1 was.
Worked example 3: a right-tailed one-sample z-test
A test is scaled to a population mean of 500 with σ = 100. A school’s 64 students average x̄ = 524. The school predicted in advance that its students score higher, so test H₀: μ = 500 against H₁: μ > 500 at α = 0.05. Click the Test scores (right-tailed) example to load it.
- SE = 100 / √64 = 12.5.
- z = (524 − 500) / 12.5 = 1.92.
- Right-tailed p = P(Z ≥ 1.92) = 0.0274; the right-tailed critical value is 1.645, and z = 1.92 is beyond it.
- Reject H₀: the school mean is significantly above 500. A two-tailed test on the same data gives p = 0.0549 and would not reject, which is why the direction must be fixed before you look at the data.
Z critical values and the decision rule
Reject H₀ when the p-value is at most α. The equivalent rule with critical values: in a two-tailed test reject when |z| is at least the critical value, in a right-tailed test when z is at least it, and in a left-tailed test when z is at most its negative. Other levels are in the Z Critical Value Calculator.
| α | Confidence | Two-tailed | Right-tailed | Left-tailed |
|---|---|---|---|---|
| 0.10 | 90% | ±1.6449 | 1.2816 | −1.2816 |
| 0.05 | 95% | ±1.9600 | 1.6449 | −1.6449 |
| 0.01 | 99% | ±2.5758 | 2.3263 | −2.3263 |
| 0.001 | 99.9% | ±3.2905 | 3.0902 | −3.0902 |
One-sample z-test vs one-sample t-test
Both tests use the same shape of formula for one mean. The difference is the spread: the z-test plugs in a known σ, while the t-test estimates it with s and pays for that extra uncertainty with heavier-tailed critical values. The shortcut “use z when n ≥ 30” only works because t and z critical values are close at large n; it does not turn an estimated s into a known σ.
| One-sample z-test | One-sample t-test | |
|---|---|---|
| Spread used | Population σ, known in advance | Sample s, estimated from the data |
| Test statistic | z = (x̄ − μ₀) / (σ / √n) | t = (x̄ − μ₀) / (s / √n) |
| Reference distribution | Standard normal | t with n − 1 degrees of freedom |
| Two-tailed critical value, α = 0.05 | 1.96 at every n | 2.201 at n = 12; 2.045 at n = 30; 1.984 at n = 100 |
| Typical use | Process control, standardized tests, calibrated instruments | Most real studies of one mean |
One-sample z-test in Excel, R, Python and the TI-84
All four use the same formula as this calculator, so z and the p-value should match to rounding. For the full explanation of p-values, read what a p-value means.
- Excel:
=Z.TEST(range, μ₀, σ)returns the right-tailed p-value P(Z ≥ z). For a two-tailed p use=2*MIN(Z.TEST(range, μ₀, σ), 1 − Z.TEST(range, μ₀, σ)). - R: base R has no z-test function. Compute
z <- (mean(x) - mu0) / (sigma / sqrt(length(x)))and the two-tailed p with2 * pnorm(-abs(z)). - Python:
from scipy.stats import norm, thenz = (x.mean() - mu0) / (sigma / len(x) ** 0.5)andp = 2 * norm.sf(abs(z)). - TI-84: STAT → TESTS → 1:Z-Test, choose Data or Stats, enter μ₀, σ and the alternative.
Sources
The formulas, critical values and software notes on this page follow these references:
- NIST/SEMATECH e-Handbook of Statistical Methods, section 7.2.2: Are the data consistent with the assumed process mean? (the z-test for a mean with known σ).
- Microsoft Support, Z.TEST function: returns the one-tailed p-value of a z-test in Excel.
Common use cases
- Quality control: compare a batch mean with its target when the process σ is documented from historical data.
- Standardized tests: compare a group’s mean score with the national mean when the test publishes its population SD.
- Measurement checks: test whether an instrument reads a reference standard correctly when its precision σ is known.
- Teaching: learn the logic of hypothesis testing with the normal curve before moving to the t distribution.
Assumptions and limitations
- σ must be known, not estimated from this sample. Using s in place of σ with a small sample understates uncertainty; the One-Sample t-Test Calculator fixes this.
- Normality: the sampling distribution of x̄ must be approximately normal. That holds for any n if the population is normal, and roughly for n ≥ 30 otherwise by the central limit theorem.
- Independence: observations must be independent random draws from the population of interest.
- Practical importance: with a large n, a trivially small difference can be significant. Check the confidence interval and the effect size, not only the p-value.
Frequently asked questions
What is the z-test formula for one sample?
How do you calculate a one-sample z-test?
When do I use a z-test instead of a t-test for one mean?
Why does a one-sample z-test require a known population standard deviation?
What is the z value for 95% confidence?
What does the z statistic mean?
Can I use a z-test with a small sample?
Cite this page
Statculator. (2026, November 14). One-Sample Z-Test Calculator. Retrieved November 14, 2026, from https://statculator.com/hypothesis-tests/one-sample-z-test-calculator/