Skip to content
Statculator
Hypothesis Tests

One-Sample Z-Test Calculator

Free one sample z test calculator: enter x̄ (or raw data), σ, n and μ₀ to get the z statistic, p-value, critical value and decision, with the formula and steps.

Free, no sign-up Runs in your browserBy Hira Noor, BS MathematicsUpdated

Try

Choose the direction your research question predicts. Use two-tailed if any difference matters.

Must be known from outside this sample (long-run process data, a published value).

Usually 0.05 or 0.01.

Data input

A z-test needs the true population σ. If you only have the sample SD, use the one-sample t-test.

Results

z statistic
-2.2136
p-value
0.0269
Two-tailed

Reject H₀ at α = 0.05

p = 0.0269 ≤ 0.05. At the 5% significance level there is sufficient evidence that the population mean differs from 500.

Sample mean, x̄
498.6
Difference, x̄ − μ₀
-1.4
Standard error, σ / √n
0.6325
Sample size, n
40
Critical z (α = 0.05)
±1.96
95% CI for μ
(497.3604, 499.8396)
Effect size, (x̄ − μ₀) / σ
-0.35

Interpretation: The sample mean is 1.4 below μ₀, which is 2.2136 standard errors. If the true mean were μ₀, a sample mean this far away would be rare.

normal distribution curve with the shaded probability region, markers at z = -2.214z = -2.214-4-3-2-101234Standard normal distribution (z)
Shaded area: rejection region at the chosen α. Dashed line: your test statistic.

Step-by-step solution

  1. 1

    State the hypotheses

    This is a two-tailed test.

    H₀: μ = 500
    H₁: μ ≠ 500
  2. 2

    Choose the significance level

    α = 0.05
  3. 3

    Find the standard error

    SE = σ / √n = 4 / √40 = 0.6325
  4. 4

    Calculate the test statistic

    z = (x̄ − μ₀) / SE = (498.6 − 500) / 0.6325 = -2.2136
  5. 5

    Find the p-value

    Use the standard normal distribution.

    p = 2 × P(z ≥ |-2.2136|) = 0.0269
  6. 6

    Find the critical value

    Critical value: ±1.96
    Reject H₀ if |z| ≥ 1.96
  7. 7

    Decision: reject H₀

    At the 5% significance level there is sufficient evidence that the population mean differs from 500.

    p = 0.0269 ≤ α = 0.05
  8. 8

    Confidence interval and effect size

    95% CI = x̄ ± 1.96 × SE = 498.6 ± 1.96 × 0.6325 = (497.3604, 499.8396)
    d = (x̄ − μ₀) / σ = -0.35

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

  1. Choose the alternative hypothesis: two-tailed (≠) unless you predicted a direction before collecting the data, otherwise left-tailed (<) or right-tailed (>).
  2. Enter the hypothesized mean μ₀, the known population standard deviation σ and the significance level α, usually 0.05.
  3. 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).
  4. 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:

  1. State the hypotheses: H₀: μ = μ₀ and H₁: μ ≠ μ₀, μ < μ₀ or μ > μ₀.
  2. Choose the significance level α, usually 0.05.
  3. Find the sample mean x̄ (x̄ = Σx / n if you have raw data) and note n and the known σ.
  4. Compute the standard error of the mean: SE = σ / √n.
  5. Calculate the test statistic: z = (x̄ − μ₀) / SE.
  6. 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.
  7. 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.

Standard error
SE = σ / √n
Test statistic
z = (x̄ − μ₀) / (σ / √n)
p-value
two-tailed: 2 · P(Z ≥ |z|); right-tailed: P(Z ≥ z); left-tailed: P(Z ≤ z)
Confidence interval for μ
x̄ ± z* · σ / √n (z* = 1.96 for 95%)
Formula symbols
SymbolMeaning
x̄sample mean
μ₀hypothesized population mean from H₀
σknown population standard deviation
nsample size
Za 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).

  1. 01Standard error: SE = 4 / √40 = 0.6325.
  2. 02z = (498.6 − 500) / 0.6325 = −2.2136.
  3. 03Two-tailed p-value = 2 · P(Z ≥ 2.2136) ≈ 0.0269.
  4. 04Critical values: ±1.96. Since |z| = 2.21 > 1.96, z falls in the rejection region.
  5. 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.

  1. Sample mean: x̄ = 5,976 / 12 = 498.
  2. Standard error: SE = 4 / √12 = 1.1547.
  3. z = (498 − 500) / 1.1547 = −1.7321.
  4. Two-tailed p = 2 · P(Z ≥ 1.7321) = 0.0833, which is above 0.05, and |z| = 1.73 is inside ±1.96.
  5. 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.

  1. SE = 100 / √64 = 12.5.
  2. z = (524 − 500) / 12.5 = 1.92.
  3. Right-tailed p = P(Z ≥ 1.92) = 0.0274; the right-tailed critical value is 1.645, and z = 1.92 is beyond it.
  4. 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.

Critical values of z for common significance levels
αConfidenceTwo-tailedRight-tailedLeft-tailed
0.1090%±1.64491.2816−1.2816
0.0595%±1.96001.6449−1.6449
0.0199%±2.57582.3263−2.3263
0.00199.9%±3.29053.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 and t-test compared
One-sample z-testOne-sample t-test
Spread usedPopulation σ, known in advanceSample s, estimated from the data
Test statisticz = (x̄ − μ₀) / (σ / √n)t = (x̄ − μ₀) / (s / √n)
Reference distributionStandard normalt with n − 1 degrees of freedom
Two-tailed critical value, α = 0.051.96 at every n2.201 at n = 12; 2.045 at n = 30; 1.984 at n = 100
Typical useProcess control, standardized tests, calibrated instrumentsMost 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 with 2 * pnorm(-abs(z)).
  • Python: from scipy.stats import norm, then z = (x.mean() - mu0) / (sigma / len(x) ** 0.5) and p = 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:

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?

z = (x̄ − μ₀) / (σ / √n), where x̄ is the sample mean, μ₀ the hypothesized mean, σ the known population standard deviation and n the sample size. The denominator σ / √n is the standard error of the mean.

How do you calculate a one-sample z-test?

State H₀: μ = μ₀ and the alternative, find the standard error σ / √n, compute z = (x̄ − μ₀) / SE, then read the p-value from the standard normal curve. Reject H₀ if p ≤ α. For x̄ = 498.6, μ₀ = 500, σ = 4 and n = 40, z = −2.21 and the two-tailed p = 0.027.

When do I use a z-test instead of a t-test for one mean?

Use a z-test only when the population standard deviation σ is known from outside the sample. If you calculate the standard deviation from the sample itself, use the t-test. With large samples (several hundred) the two give nearly identical results.

Why does a one-sample z-test require a known population standard deviation?

The z statistic follows the standard normal distribution only when the standard error σ / √n is a fixed, known quantity. If σ is replaced by the sample SD s, the statistic gains extra variability and follows a t distribution instead, so z-based p-values would be too small.

What is the z value for 95% confidence?

For a two-tailed test at α = 0.05 (95% confidence) the critical values are ±1.96. For a right-tailed test it is 1.645, and for a left-tailed test −1.645. At α = 0.01 the two-tailed values widen to ±2.576.

What does the z statistic mean?

The z statistic is the distance between the sample mean and μ₀ measured in standard errors. z = −2.21 means the sample mean is 2.21 standard errors below the hypothesized value. Values beyond ±1.96 are unusual under H₀ for a two-tailed test at the 5% level.

Can I use a z-test with a small sample?

Yes, provided σ is known and the population is normal; then the z statistic is exactly standard normal for any n. If the population might be skewed, small samples make the normal approximation unreliable, and a larger sample or a nonparametric test is safer.

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/