Z Test Calculator

This z test calculator computes test statistics, critical values, and p-values using your sample mean, known population standard deviation, sample size, and hypothesized mean. It eliminates manual normal distribution table lookups, helping you verify statistical significance instantly without complex hand calculations. Whether you analyze quality control metrics on a factory floor or evaluate conversion rate lifts in split testing, it reveals whether observed differences are genuine or simply random noise.

One sample mean
H0:μ=μ0H1:μ≠μ0H_0: \mu = \mu_0 \quad H_1: \mu \neq \mu_0
Test result
Significant
Test statistic
z = 2.1082
p = 0.035015

p is at or below 0.05, so reject the null hypothesis.

Where the statistic falls

z = 2.11-3-2-10123shaded area is the rejection region
p value
0.035015
two tailed
Critical value
±1.96
at alpha 0.05
Standard error
2.37171
of the estimate
95% confidence interval
100.3515 to 109.6485
for the population mean
Cohen's d
0.3333
Small effect
Achieved power
55.9%
below the usual 80% target

Assumption checks

Sample size at least 30 — n = 40, the sampling distribution is safely normal
Population standard deviation known — A z test assumes sigma is known. If you estimated it from the sample, a t test is the correct choice
Power of 55.9% means that if an effect this size is real, a study like this would only detect it 56 times in 100. A non significant result here is weak evidence of no effect rather than evidence of none.
Portrait of Natasha Okonkwo

Created by Natasha Okonkwo

Last updated: September 26, 2026

What Is a Z Test?

A z test is a parametric statistical hypothesis test used to determine whether sample means differ significantly from a population mean or another sample mean. It evaluates data points against the standard normal distribution, commonly referred to as the Gaussian or Z distribution.

Statisticians rely on this test when the population standard deviation (σ\sigma) is known, or when working with large sample sizes (n≥30n \ge 30) under the Central Limit Theorem. The test produces a test statistic called a z-score. This score measures exactly how many standard errors an observed sample mean sits away from the null hypothesis mean.

When conducting statistical inference, choosing the right test is critical. If your dataset lacks a known population standard deviation and relies strictly on a small sample estimate, you should use a t-test calculator instead of a normal distribution test.

How to Use the Z Test Calculator

Running your calculation requires five simple inputs:

  1. Select the Test Type: Choose between a One-Sample Mean Test, a Two-Sample Mean Test, a One-Sample Proportion Test, or a Two-Sample Proportion Test.
  2. Enter the Null and Sample Values: Provide your hypothesized population mean (μ0\mu_0), observed sample mean (xˉ\bar{x}), known population standard deviation (σ\sigma), and sample size (nn).
  3. Select the Alternative Hypothesis Direction:
    • Two-tailed (≠\neq): Tests for any significant difference in either direction.
    • Left-tailed (<<): Tests whether the sample mean is significantly smaller than the hypothesized mean.
    • Right-tailed (>>): Tests whether the sample mean is significantly larger than the hypothesized mean.
  4. Set Your Significance Level (α\alpha): Select standard options like 0.05 (95% confidence) or 0.01 (99% confidence), or enter a custom decimal value.
  5. Read the Instant Results: The calculator displays the standard error, computed z-score, critical z-values, p-value, and an automated decision on whether to reject or fail to reject the null hypothesis.

Formulas Used in the Calculations

The test compares your observed data against theoretical expectations using standardized formulas.

1. One-Sample Z Test for a Mean

When comparing a single sample mean to a known population benchmark:

z=xˉ−μ0σ/nz = \frac{\bar{x} - \mu_0}{\sigma / \sqrt{n}}

Where:

  • xˉ\bar{x} = Observed sample mean
  • μ0\mu_0 = Hypothesized population mean under the null hypothesis (H0H_0)
  • σ\sigma = Known population standard deviation
  • nn = Sample size
  • σ/n\sigma / \sqrt{n} = Standard error of the mean (SESE)

2. Two-Sample Z Test for Comparing Means

When comparing two independent groups where both population standard deviations (σ1,σ2\sigma_1, \sigma_2) are known:

z=(xˉ1−xˉ2)−Δ0σ12n1+σ22n2z = \frac{(\bar{x}_1 - \bar{x}_2) - \Delta_0}{\sqrt{\frac{\sigma_1^2}{n_1} + \frac{\sigma_2^2}{n_2}}}

Where:

  • xˉ1,xˉ2\bar{x}_1, \bar{x}_2 = Sample means of groups 1 and 2
  • Δ0\Delta_0 = Hypothesized difference between the two population means (typically 0)
  • σ1,σ2\sigma_1, \sigma_2 = Known population standard deviations
  • n1,n2n_1, n_2 = Respective sample sizes

If you want to estimate the full range of likely values for the true mean rather than just testing a single threshold, pair your findings with a confidence interval calculator.

3. One-Sample Z Test for a Proportion

When comparing a single observed proportion against a benchmark value, the standard error is built from the null proportion rather than the observed one, because that is the variance the null hypothesis asserts:

z=p^−p0p0(1−p0)n,p^=xnz = \frac{\hat{p} - p_0}{\sqrt{\frac{p_0(1 - p_0)}{n}}}, \quad \hat{p} = \frac{x}{n}

Where:

  • p^\hat{p} = Observed sample proportion, successes divided by trials
  • p0p_0 = Hypothesised population proportion under H0H_0
  • xx = Number of successes
  • nn = Number of trials

Note that the confidence interval for a proportion uses the observed p^\hat{p} in its standard error, not p0p_0. The calculator applies each in the right place, which is why the interval is not simply the test statistic rearranged.

4. Two-Sample Z Test for Proportions

When comparing the proportion of successes between two independent groups, the calculator pools both samples to estimate the standard error under the null hypothesis of no difference:

z=p^1−p^2p^(1−p^)(1n1+1n2),p^=x1+x2n1+n2z = \frac{\hat{p}_1 - \hat{p}_2}{\sqrt{\hat{p}(1 - \hat{p})\left(\frac{1}{n_1} + \frac{1}{n_2}\right)}}, \quad \hat{p} = \frac{x_1 + x_2}{n_1 + n_2}

Where p^1\hat{p}_1 and p^2\hat{p}_2 are the observed proportions in each group, and p^\hat{p} is the pooled proportion across both samples combined.

Understanding Key Inputs and Outputs

Entering accurate numbers ensures reliable outputs. Here is what each variable means in practice.

MetricTypePurpose & Practical Meaning
Sample Mean (x̄)InputThe arithmetic average computed from your gathered sample data.
Hypothesized Mean (μ₀)InputThe historical baseline or theoretical standard assumed true under H₀.
Population Std Dev (σ)InputThe known variability across the entire population, not an estimated sample standard deviation.
Sample Size (n)InputTotal number of independent observations. Must be at least 30 if normality cannot be assumed.
Significance Level (α)InputThe probability threshold for committing a Type I error (false positive), commonly set at 0.05.
Standard Error (SE)OutputThe standard deviation of the sampling distribution (σ / √n). Shows dispersion across samples.
Z-Score (z)OutputThe number of standard errors separating your observed mean from the baseline.
P-ValueOutputThe exact probability of observing results as extreme as yours assuming H₀ is true.
Critical Values (z_crit)OutputCutoff boundaries determined by α. For a two-tailed test at α = 0.05, these are ±1.960.

Step-by-Step Worked Example

Normal distribution curve showing z test critical values at 1.96 and a calculated z score of 2.40 in rejection region.

Suppose an industrial bottling facility calibrates machines to dispense 500.0 mL of beverage per bottle. Historical production data confirms that the dispensing process follows a normal distribution with a known population standard deviation (σ\sigma) of 4.0 mL.

A quality assurance technician randomly samples 64 bottles from the morning production run. The sample mean (xˉ\bar{x}) measures 501.2 mL. Does this batch deviate significantly from the 500.0 mL target at a 5% significance level (α=0.05\alpha = 0.05)?

Step 1: State the Hypotheses

  • Null Hypothesis (H0H_0): μ=500.0\mu = 500.0 (The machine is dispensing correctly).
  • Alternative Hypothesis (H1H_1): μ≠500.0\mu \neq 500.0 (Two-tailed test; the machine is over-dispensing or under-dispensing).

Step 2: Identify the Input Variables

  • xˉ=501.2\bar{x} = 501.2
  • μ0=500.0\mu_0 = 500.0
  • σ=4.0\sigma = 4.0
  • n=64n = 64
  • α=0.05\alpha = 0.05

Step 3: Compute the Standard Error of the Mean

SE=σn=4.064=4.08=0.50 mLSE = \frac{\sigma}{\sqrt{n}} = \frac{4.0}{\sqrt{64}} = \frac{4.0}{8} = 0.50 \text{ mL}

Step 4: Calculate the Z Statistic

z=xˉ−μ0SE=501.2−500.00.50=1.20.50=2.40z = \frac{\bar{x} - \mu_0}{SE} = \frac{501.2 - 500.0}{0.50} = \frac{1.2}{0.50} = 2.40

Step 5: Determine Critical Values and P-Value

For a two-tailed test at α=0.05\alpha = 0.05, critical boundaries sit at z=±1.960z = \pm 1.960.

The p-value corresponds to the probability of finding ∣z∣≥2.40|z| \ge 2.40.

Using the standard normal distribution table: P(Z>2.40)≈0.0082P(Z > 2.40) \approx 0.0082.

Multiplying by two for both tails gives p=2×0.0082=0.0164p = 2 \times 0.0082 = 0.0164.

Step 6: Interpret the Result

Because the calculated test statistic (z=2.40z = 2.40) exceeds the upper critical threshold (1.9601.960), and the p-value (0.01640.0164) is less than our significance level (α=0.05\alpha = 0.05), we reject the null hypothesis. The quality control engineer has sufficient statistical evidence that the morning bottling line is overfilling bottles, requiring machine recalibration.

How to Interpret Your Z Test Results

Making an informed decision from your test output involves two parallel decision approaches: the Critical Value Approach and the P-Value Approach. Both yield identical conclusions.

z = 2.4-3-2-10123shaded area is the rejection region

The worked example above: z = 2.40 falls in the shaded rejection region beyond ±1.960, so H₀ is rejected.

The P-Value Approach

Compare your calculated p-value directly against your chosen alpha (α\alpha):

  • If p≤αp \le \alpha: Reject the null hypothesis (H0H_0). The data provides strong evidence that the observed effect is statistically significant.
  • If p>αp > \alpha: Fail to reject the null hypothesis (H0H_0). The observed difference could easily happen by chance.

The Critical Value Approach

Compare your test statistic (zz) against the critical cutoff values (zcritz_{crit}):

  • Two-Tailed Test: Reject H0H_0 if z<−zcritz < -z_{crit} or z>+zcritz > +z_{crit}.
  • Left-Tailed Test: Reject H0H_0 if z<−zcritz < -z_{crit}.
  • Right-Tailed Test: Reject H0H_0 if z>+zcritz > +z_{crit}.

When planning experimental trials where detecting subtle differences is mandatory, run a sample size calculator beforehand to ensure your study gathers enough observations to achieve adequate statistical power.

Assumptions and Limitations

A z test provides rigorous mathematical guarantees, but only when your dataset satisfies core assumptions:

  • Known Population Standard Deviation: The exact population parameter σ\sigma must be known beforehand from historical census data or engineering specifications. If you estimate standard deviation using sample data (ss), switch to a Student's t-test.
  • Normality or Large Sample Size: The underlying population distribution must be normal, or the sample size must be large (n≥30n \ge 30). Under the Central Limit Theorem, sampling distributions of the mean approach normality as sample sizes expand.
  • Independent Observations: Every measurement must be collected independently. Sampling without replacement from small populations requires finite population corrections.
  • Continuous Scale: The measured variable must sit on a continuous ratio or interval scale for mean tests.

Common Mistakes to Avoid

Even seasoned analysts occasionally stumble on subtle statistical nuances:

  • Treating Sample Standard Deviation as Population Sigma: Entering sample standard deviation (ss) directly into a z test formula when sample sizes are small (n<30n < 30) inflates Type I errors. Always use a t-test when population dispersion is unknown.
  • Mismatched Tails: Choosing a one-tailed test after seeing the sample mean creates confirmation bias. Specify your alternative hypothesis direction before collecting or examining data.
  • Confusing Statistical Significance with Practical Significance: A microscopic difference can become statistically significant (p<0.05p < 0.05) when sample sizes reach tens of thousands. Always inspect raw effect sizes before enacting expensive operational changes.
  • Rounding Errors in Intermediate Steps: Rounding the standard error to one decimal place before dividing can shift your computed z-score noticeably. Carry four or more decimal places through intermediate steps.

Frequently Asked Questions

When should I use a z test instead of a t test?

Use a z test when you know the population standard deviation (σ\sigma) or when your sample size exceeds 30 with known dispersion. If the population standard deviation is unknown and must be estimated from your sample, use a t-test instead.

Can the z-score be negative?

Yes. A negative z-score simply indicates that your observed sample mean sits below the hypothesized population mean.

What is the difference between a one-tailed and two-tailed z test?

A two-tailed test evaluates whether a sample mean is significantly different in either direction from the null value. A one-tailed test specifically checks for directional differences, testing exclusively whether the mean is greater than or less than the benchmark.

What does a p-value of 0.05 mean?

A p-value of 0.05 means there is a 5% probability of observing a test statistic at least as extreme as the one calculated, assuming the null hypothesis is completely true.

Does a large sample size guarantee valid z test results?

Not necessarily. While large sample sizes fulfill normality requirements via the Central Limit Theorem, they cannot correct for selection bias, measurement flaws, or non-independent sampling methods.

What critical value corresponds to a 95% confidence level?

For a two-tailed test at a 95% confidence level (α=0.05\alpha = 0.05), the critical z-values are ±1.960\pm 1.960. For a one-tailed test at the same level, the critical value is either +1.645+1.645 or −1.645-1.645.

Can I run a z test on proportion data?

Yes. The calculator has a one-sample proportion tab and a two-sample proportion tab. The normal approximation to the binomial holds when both n×p0n \times p_0 and n×(1−p0)n \times (1 - p_0) reach 10, which is the threshold the assumption checks apply. Older texts use 5, but 10 is the modern convention and the safer one near the extremes of the proportion scale.

What should I do if my calculated z-score falls exactly on the critical value?

If your test statistic matches the critical value exactly, the p-value equals alpha (α\alpha). By standard statistical convention, you reject the null hypothesis.

Related Calculators