Z-Test Calculator
Perform a one-sample z-test or two-proportion z-test. Calculate z-statistics, p-values, and confidence intervals when the population standard deviation is known. Related tools: T-Test Calculator, Normal Distribution Calculator, and P-Value Calculator.
How to Use the Z-Test Calculator
The z-test is a hypothesis test used when the population standard deviation is known or when comparing proportions from large samples. The one-sample z-test compares a sample mean to a known population mean using the known population standard deviation. The two-proportion z-test compares proportions from two independent groups to determine if they differ significantly.
For the one-sample test, enter the sample mean, population mean (null hypothesis value), population standard deviation, and sample size. For the two-proportion test, enter each group's observed proportion and sample size. Select the tail type based on your alternative hypothesis and click Calculate.
The z-test is appropriate when: (1) the population standard deviation σ is known (one-sample), (2) sample sizes are large enough for the normal approximation (np ≥ 5 and n(1-p) ≥ 5 for proportions), and (3) observations are independent. When σ is unknown, use the t-test instead.
Formula
One-Sample Z-Test:
z = (x̄ - μ₀) / (σ / √n)
Two-Proportion Z-Test:
z = (p̂₁ - p̂₂) / √(p̂(1-p̂)(1/n₁ + 1/n₂))
where p̂ = (x₁ + x₂) / (n₁ + n₂) is the pooled proportion
Confidence Interval (one-sample):
CI = x̄ ± z*(α/2) × (σ / √n)
Confidence Interval (proportions):
CI = (p̂₁ - p̂₂) ± z*(α/2) × √(p̂₁(1-p̂₁)/n₁ + p̂₂(1-p̂₂)/n₂)
Example Calculation
A factory claims mean widget weight is 50g (σ = 5g). A sample of 36 widgets has mean 52g. Test at α = 0.05:
Given: x̄ = 52, μ₀ = 50, σ = 5, n = 36
SE = σ/√n = 5/√36 = 5/6 = 0.8333
z = (52 - 50) / 0.8333 = 2.400
p-value (two-tailed) = 2 × P(Z > 2.4) = 2 × 0.0082 = 0.0164
Since p = 0.0164 < α = 0.05, reject H₀
95% CI: [52 - 1.633, 52 + 1.633] = [50.367, 53.633]
Conclusion: The mean weight significantly differs from 50g.
Z Critical Values Reference Table
| α (significance) | z (one-tailed) | z (two-tailed) |
|---|---|---|
| 0.10 | 1.282 | 1.645 |
| 0.05 | 1.645 | 1.960 |
| 0.025 | 1.960 | 2.240 |
| 0.01 | 2.326 | 2.576 |
| 0.005 | 2.576 | 2.807 |
| 0.001 | 3.090 | 3.291 |
| 0.0005 | 3.291 | 3.481 |
| 0.0001 | 3.719 | 3.891 |
Step-by-Step Decision Process
- Verify conditions: Population standard deviation (sigma) is known, OR n > 30 (use sample SD as estimate).
- State hypotheses: H0: mu = mu_0 (population mean equals hypothesized value). H1: mu != mu_0 (or > or < for one-tailed).
- Calculate standard error: SE = sigma / sqrt(n).
- Compute z-statistic: z = (x_bar - mu_0) / SE.
- Find p-value: Use the standard normal distribution (no degrees of freedom needed).
- Compare to alpha: If p < alpha, reject H0. Otherwise fail to reject.
- Construct confidence interval: x_bar +/- z_(alpha/2) x SE.
Additional Solved Examples
Example: Testing Product Weight
A cereal company claims boxes contain 500g on average. Population sigma = 15g. A sample of 36 boxes has mean 495g. Test at alpha = 0.05 (two-tailed).
H0: mu = 500, H1: mu != 500
SE = 15/sqrt(36) = 15/6 = 2.5
z = (495 - 500)/2.5 = -5/2.5 = -2.0
p-value (two-tailed) = 2 x P(Z < -2.0) = 2(0.0228) = 0.0456
Since 0.0456 < 0.05, reject H0
95% CI: 495 +/- 1.96(2.5) = (490.1, 499.9)
Answer: The evidence suggests the true mean weight is significantly less than 500g (z = -2.0, p = 0.046). The 95% CI of (490.1, 499.9) does not include 500, confirming the finding.
Example: Proportion Test (Large Sample Z-Test)
A politician claims 60% support. A poll of 400 people shows 52% support. Test at alpha = 0.01.
H0: p = 0.60, H1: p < 0.60 (one-tailed)
SE = sqrt(p0(1-p0)/n) = sqrt(0.60 x 0.40/400) = sqrt(0.0006) = 0.0245
z = (0.52 - 0.60)/0.0245 = -0.08/0.0245 = -3.27
p-value (one-tailed) = P(Z < -3.27) = 0.0005
Since 0.0005 < 0.01, reject H0
Answer: The data provides strong evidence that true support is below 60% (z = -3.27, p = 0.0005). The poll contradicts the politician's claim even at the stringent 0.01 significance level.
Interpreting Results
Z-Test vs T-Test: When to Use Each
| Condition | Use Z-Test | Use T-Test |
|---|---|---|
| Population SD known? | Yes | No (estimate from sample) |
| Sample size | Large (n > 30) | Any size |
| Distribution used | Standard normal (Z) | t with df = n-1 |
| In practice | Proportions, quality control | Most research settings |
Key Takeaways
- The z-test uses the standard normal distribution and requires known population standard deviation or large samples.
- For proportions, the z-test is standard: z = (p_hat - p_0) / sqrt(p_0(1-p_0)/n).
- Critical values: z = 1.645 for one-tailed alpha=0.05, z = 1.96 for two-tailed alpha=0.05, z = 2.576 for two-tailed alpha=0.01.
- The z-test is computationally simpler than the t-test since it does not require degrees of freedom.
- In modern practice, the t-test is preferred for means since population sigma is rarely known exactly.
Frequently Asked Questions
What is a z-test?
A z-test is a statistical hypothesis test that uses the standard normal distribution to determine whether a sample statistic differs significantly from a hypothesized population parameter. It requires that the population standard deviation is known (for means) or that sample sizes are large enough for the normal approximation (for proportions). The test statistic z measures how many standard errors the sample statistic is from the null hypothesis value.
When should I use a z-test instead of a t-test?
Use a z-test when: (1) the population standard deviation σ is known, (2) you are comparing proportions with large samples (np ≥ 5 and n(1-p) ≥ 5), or (3) your sample size is very large (n > 100) and you treat s as σ. In practice, the t-test is preferred for comparing means because σ is rarely known. The two-proportion z-test is standard for comparing proportions regardless of whether you call it a z-test.
How do I interpret the z-statistic?
The z-statistic tells you how many standard errors your sample statistic is from the null hypothesis value. A z of 0 means the sample exactly matches H₀. A z of ±1.96 corresponds to the 5% significance level (two-tailed). Larger absolute z-values indicate stronger evidence against H₀. The sign indicates direction: positive z means the sample is above H₀, negative means below.
What is the two-proportion z-test used for?
The two-proportion z-test determines whether two population proportions are significantly different. Common applications include A/B testing (comparing conversion rates), clinical trials (comparing treatment success rates), and survey analysis (comparing response rates between groups). It uses a pooled proportion under H₀: p₁ = p₂ to estimate the standard error.
What are the assumptions of the z-test?
The z-test assumes: (1) observations are independent, (2) the sampling distribution of the statistic is approximately normal (guaranteed by CLT for large n), (3) for one-sample mean tests, σ is known, (4) for proportion tests, np ≥ 5 and n(1-p) ≥ 5 in each group. Violations of the normality assumption are less concerning with large samples due to the Central Limit Theorem.
How do I calculate the confidence interval from a z-test?
For a one-sample mean: CI = x̄ ± z*(α/2) × (σ/√n). For two proportions: CI = (p̂₁ - p̂₂) ± z*(α/2) × √(p̂₁(1-p̂₁)/n₁ + p̂₂(1-p̂₂)/n₂). Note that the CI for proportions uses unpooled standard errors (each proportion's own variance), while the test statistic uses the pooled proportion. Common z* values: 1.645 (90%), 1.960 (95%), 2.576 (99%).