Calculateus

Two-Sample Z-Test Calculator

Calculate the z-statistic for comparing two independent sample means when population standard deviations are known.

Result

Z-Statistic
1.8472
Two-Tailed P-Value
0.0647

About the Two-Sample Z-Test

The Two-Sample Z-Test Calculator computes the z-statistic for comparing two independent sample means in the less common situation where both groups' population standard deviations are already known precisely. It also returns a two-tailed p-value directly from the standard normal distribution, rather than requiring a separate table lookup.

How It Works

Enter each group's mean, known population standard deviation, and sample size. The calculator combines both groups' variance-over-size terms into a standard error, divides the difference between the two means by that standard error to get the z-statistic, and converts the absolute z-statistic into a two-tailed p-value using the cumulative normal distribution function.

SE = sqrt(popSd1^2/n1 + popSd2^2/n2), z = (mean1 - mean2)/SE, two-tailed p-value = 2 x (1 - normalCdf(|z|)).

Formula & Methodology

To calculate by hand, square each group's known population standard deviation, divide by that group's sample size, add the two results together, and take the square root to get the standard error. Divide the difference between the two sample means by the standard error to obtain the z-statistic. For the two-tailed p-value, look up the cumulative probability of the standard normal distribution at the absolute value of z, subtract that from 1, and double the result to account for both tails.

Examples

Standardized Test Comparison

Group 1 (mean 82, known population sd 10, n=50) versus Group 2 (mean 78, known population sd 11, n=45) gives SE = sqrt(100/50 + 121/45) = sqrt(4.689) = 2.165, so z = (82-78)/2.165 = 1.848, with a two-tailed p-value around 0.0646.

Manufacturing Line Output

Line A (mean 500g, population sd 8, n=100) versus Line B (mean 504g, population sd 8, n=100) gives SE = sqrt(64/100 + 64/100) = sqrt(1.28) = 1.131, so z = (500-504)/1.131 = -3.537, with a two-tailed p-value well under 0.001.

Advantages

  • Returns an exact two-tailed p-value computed from the normal distribution, rather than only a test statistic requiring a separate table lookup.
  • Appropriate for situations with genuinely known population variability, such as standardized instruments or long-established manufacturing tolerances.
  • Its required inputs make explicit that this test assumes known population standard deviations rather than sample-estimated ones, helping avoid misapplying it to ordinary sample data.

Common Mistakes

  • Using this z-test with standard deviations estimated from the samples themselves rather than genuinely known population values, which understates uncertainty compared to the appropriate t-test.
  • Treating a small p-value as evidence of a large practical difference, when very large sample sizes can make even a trivial mean difference statistically significant.
  • Misreading the p-value as one-tailed when the underlying formula specifically doubles the tail probability to produce a two-tailed result.

Edge Cases to Watch For

  • All four inputs, both sample sizes and both population standard deviations, must be greater than zero, or the calculator returns an error rather than dividing by zero.
  • This test requires knowing the true population standard deviations in advance rather than estimating them from the samples, a condition that is uncommon outside tightly standardized measurement processes.
  • The reported p-value is two-tailed by construction, doubling the tail probability, so it tests for any difference between the means rather than one in a predicted direction.

Common Use Cases

  • Analysts working with standardized instruments or processes where population variability is documented and effectively fixed.
  • Statistics students comparing the z-test and t-test approaches side by side to see how each handles known versus estimated standard deviations.
  • Manufacturing or process engineers comparing two production lines' average output when each line's variability is established from long-run historical data.
Written & fact-checked by the Calculateus TeamLast updated August 5, 2026How we verify our formulas

Frequently asked questions

How is this different from the Two-Sample T-Test Calculator?

This z-test assumes the population standard deviations of both groups are already known precisely, which is uncommon outside of highly standardized measurement processes. The Two-Sample T-Test Calculator instead estimates standard deviation from each sample, which is the far more typical real-world situation and produces a more conservative (wider) test.

Conclusion

The Two-Sample Z-Test Calculator computes a z-statistic and two-tailed p-value for comparing two means when population standard deviations are known rather than estimated. Because that condition is fairly specific, it is worth confirming your standard deviations are genuine population values before relying on this test over the more commonly applicable two-sample t-test.