Two Sample Z-Test Calculator

Use this free online Two Sample Z-Test Calculator to determine whether the difference between two independent sample means (x̄₁ − x̄₂) is statistically significant when both population standard deviations (σ₁, σ₂) are known. Enter your group averages, known variances, sample sizes (n₁, n₂), and significance level (α) to instantly compute the standard error of the difference, standardized z-statistic, exact directional p-values, critical bounds, and confidence intervals of the difference with full step-by-step derivations.

Sample 1 (Group 1)
Sample 2 (Group 2)
Test settings
Alternative hypothesis (H₁)
Significance level α

Live Two Sample Standard Normal Distribution (Z-Curve)

Visualise the difference of means calibrated on the standard normal scale.

−4−3−2−10+1+2+3+4z = 1.73
Fine Adjust z:1.73
Rejection Zone (α = 0.05)p-value Area (0.0836)

Step-by-Step Mathematical Derivation

1

State Hypotheses

Hypothesize the difference between the two population means:

H₀: μ₁ − μ₂ = 0
H₁: μ₁ − μ₂ ≠ 0
2

Calculate Difference & SE

Compute the observed difference and combined standard error:

Diff = x̄₁ − x̄₂ = 78.4 − 74.9 = 3.500
SE = √(σ₁²/n₁ + σ₂²/n₂) = 2.0215
3

Compute Z-Statistic

Subtract hypothesized difference and scale by the standard error:

z = [(x̄₁ − x̄₂) − Δ₀] / SE
z = (3.500 − 0) / 2.0215 = 1.7314
4

Evaluate Significance

Compare z against critical boundary and calculate p-value:

Critical z* = ±1.960 (α = 0.05)
P-Value = 0.0834
Insufficient evidence: Fail to reject H₀

What Is a Two Sample Z-Test Calculator?

A two sample z-test calculator is an online statistical tool that evaluates whether the difference between the means of two independent populations is statistically significant when both population standard deviations (σ₁ and σ₂) are known. The calculator computes the z statistic, standard error of the difference, p-value, critical value boundaries, and the confidence interval for the difference between population means (μ₁ − μ₂).

There are 4 main benefits of using a Two Sample Z Test Calculator:

1. Instant Mathematical Accuracy

Eliminates manual arithmetic errors in pooling population variances and computing complex square root denominators.

2. Exact Tail Probabilities

Computes precise p-values for two-tailed, left-tailed, and right-tailed tests without rounding errors from printed z-tables.

3. Step-by-Step Statistical Proof

Generates a full six-step hypothesis test solution showing hypotheses, standard error, test statistic, and rejection thresholds.

4. Visual Decision Mapping

Renders the standard normal distribution curve displaying the calculated z score directly against shaded rejection regions.

Statisticians refer to this procedure by 4 alternative names:

  • Two sample z test for means
  • Independent samples z test
  • Two population means z test
  • Z test for the difference between two means

How to Use the Two Sample Z Test Calculator

To use the two sample z test calculator, enter your sample statistics for Sample 1 and Sample 2, specify the known population standard deviations, select your alternative hypothesis, and click calculate.

  1. Select the Alternative Hypothesis:Choose between a two-tailed test (μ₁ − μ₂ ≠ Δ₀), left-tailed test (μ₁ − μ₂ < Δ₀), or right-tailed test (μ₁ − μ₂ > Δ₀) to match your study design.
  2. Set the Significance Level (α): Select α = 0.05 for a standard 95% confidence threshold, or set α = 0.01 for strict experimental controls.
  3. Enter Sample 1 Parameters: Provide the sample mean (x̄₁), known population standard deviation (σ₁), and sample size (n₁).
  4. Enter Sample 2 Parameters: Provide the sample mean (x̄₂), known population standard deviation (σ₂), and sample size (n₂).
  5. Specify Hypothesized Difference (Δ₀): Leave Δ₀ = 0 to test whether the two population means are identical (μ₁ = μ₂), or enter a non-zero constant if testing a specified target gap.
  6. Inspect Results: Review the calculated z statistic, p-value, critical values, confidence interval bounds, and dynamic normal curve graphic.
Summary Data vs. Raw Data Input

Use Summary Data if you already have the calculated sample average (x̄₁, x̄₂) and sample size (n₁, n₂) for each group. Compute individual averages and counts first from your spreadsheet (such as Microsoft Excel or Google Sheets), if you have raw data observations, and enter those summary metrics into the calculator alongside the known population standard deviations.

Two Sample Z Test Formula and Standard Error

The two sample z test statistic formula standardizes the difference between two sample averages using the combined standard error of independent populations.

z = [(x̄₁ − x̄₂) − (μ₁ − μ₂)₀] / √(σ₁²/n₁ + σ₂²/n₂)

Set (μ₁ − μ₂)₀ = 0, if the null hypothesis assumes equal population means (μ₁ = μ₂). This simplifies the test statistic formula:

z = (x̄₁ − x̄₂) / √(σ₁²/n₁ + σ₂²/n₂)

Formula Notation Breakdown:

  • z: The calculated two sample z statistic.
  • x̄₁: The sample average of Group 1.
  • x̄₂: The sample average of Group 2.
  • σ₁: The known population standard deviation of Population 1.
  • σ₂: The known population standard deviation of Population 2.
  • n₁: The sample size of Group 1.
  • n₂: The sample size of Group 2.
  • (μ₁ − μ₂)₀: The hypothesized difference between population means (often zero).

The denominator represents the standard error of the difference between two independent means:

SE(x̄₁ − x̄₂) = √(σ₁²/n₁ + σ₂²/n₂)

Because variances are additive for independent random variables, the total variance of the difference equals σ₁²/n₁ + σ₂²/n₂. Taking the square root produces the standard error on the original measurement scale.

Null and Alternative Hypotheses for Two Sample Tests

The null hypothesis (H₀) states that there is no difference between the two population means, while the alternative hypothesis (H₁) states that a difference exists.

Two-Tailed Test

Tests for any difference between groups in either direction.

H₀: μ₁ − μ₂ = 0
H₁: μ₁ − μ₂ ≠ 0
Right-Tailed Test

Tests if Group 1 mean exceeds Group 2 mean.

H₀: μ₁ − μ₂ ≤ 0
H₁: μ₁ − μ₂ > 0
Left-Tailed Test

Tests if Group 1 mean is less than Group 2 mean.

H₀: μ₁ − μ₂ ≥ 0
H₁: μ₁ − μ₂ < 0

How to Perform a Two Sample Z Test: The Six Steps

There are 6 systematic steps required to execute a complete hypothesis test:

  1. State the Hypotheses: Define null hypothesis H₀: μ₁ − μ₂ = 0 and alternative hypothesis H₁ (two-tailed, right-tailed, or left-tailed).
  2. Select the Significance Level: Choose α = 0.05, 0.01, or 0.10 based on acceptable Type I error risk.
  3. Calculate the Z Statistic: Compute standard error SE = √(σ₁²/n₁ + σ₂²/n₂) and evaluate z = (x̄₁ − x̄₂) / SE.
  4. Find Critical Value and P-Value: Identify critical z thresholds from standard normal distribution tables and compute tail probabilities.
  5. Make the Statistical Decision: Reject H₀, if the p-value is less than or equal to α (p ≤ α), or if the absolute test statistic exceeds the critical value (|z| ≥ z*).
  6. State the Practical Conclusion: Formulate the result in clear language describing the real-world operational impact.

Worked Examples with Step-by-Step Solutions

Example 1: Factory Production Machines (Two-Tailed Test)

A plastics factory operates two high-speed molding machines to manufacture plastic plates. Plant engineers monitor output rates to check whether both machines produce at the same hourly rate. Historical monitoring establishes known population standard deviations of σ₁ = 4.0 plates per minute for Machine 1 and σ₂ = 3.8 plates per minute for Machine 2. A production supervisor samples 60 minutes of operation from Machine 1 (x̄₁ = 45.2 plates/min) and 60 minutes from Machine 2 (x̄₂ = 43.6 plates/min). At α = 0.05, does a significant difference exist between the two machines?

Step 1: H₀: μ₁ − μ₂ = 0 vs. H₁: μ₁ − μ₂ ≠ 0 (Two-tailed)
Step 2: α = 0.05 → Two-tailed critical z* = ±1.9600
Step 3: SE = √(4.0²/60 + 3.8²/60) = √(0.2667 + 0.2407) = √0.5073 = 0.7123
Step 4: z = (45.2 − 43.6) / 0.7123 = 1.6 / 0.7123 = 2.2462
Step 5: Two-tailed p-value = 2 · P(Z > 2.2462) = 0.02469
Step 6: Reject H₀ since p = 0.0247 < 0.05 and |z| = 2.246 > 1.960. Service Machine 2, if equal plate output is required across production lines.
Example 2: Farmer Potato Crop & Fertilizer Yield (Left-Tailed Test)

A commercial potato farmer evaluates two fertilizer mixtures. Historical regional records indicate population standard deviations of σ₁ = 3.2 kg/m² for the standard Fertilizer #1 and σ₂ = 3.0 kg/m² for the newly formulated Fertilizer #2. The farmer records yields across 40 test plots receiving Fertilizer #1 (x̄₁ = 28.5 kg/m²) and 40 plots receiving Fertilizer #2 (x̄₂ = 30.4 kg/m²). The farmer will adopt the new formula only if Fertilizer #2 produces significantly higher yields (testing H₁: μ₁ < μ₂).

Step 1: H₀: μ₁ − μ₂ ≥ 0 vs. H₁: μ₁ − μ₂ < 0 (Left-tailed)
Step 2: α = 0.05 → Left-tailed critical z* = −1.6449
Step 3: SE = √(3.2²/40 + 3.0²/40) = √(0.256 + 0.225) = √0.481 = 0.6935
Step 4: z = (28.5 − 30.4) / 0.6935 = −1.9 / 0.6935 = −2.7397
Step 5: Left-tailed p-value = P(Z < −2.7397) = 0.00307
Step 6: Reject H₀ since p = 0.00307 < 0.05 and z = −2.74 < −1.645. Adopt Fertilizer #2, if maximizing potato crop harvest is the primary objective.
Example 3: Electronics Assembly Lines (Summary Data Benchmark)

An industrial plant operates two independent automated production lines assembling consumer electronics. Long-term quality logs indicate known standard deviations of σ₁ = 6.0 units/hour and σ₂ = 5.5 units/hour. An audit samples n₁ = 50 hours from Line 1 (x̄₁ = 102.4 units/hour) and n₂ = 45 hours from Line 2 (x̄₂ = 98.7 units/hour). Test at α = 0.05 whether the lines differ in mean hourly throughput.

Step 1: H₀: μ₁ − μ₂ = 0 vs. H₁: μ₁ − μ₂ ≠ 0 (Two-tailed)
Step 2: α = 0.05 → Two-tailed critical z* = ±1.9600
Step 3: SE = √(6.0²/50 + 5.5²/45) = √(0.72 + 0.6722) = √1.3922 = 1.1799
Step 4: z = (102.4 − 98.7) / 1.1799 = 3.7 / 1.1799 = 3.1358
Step 5: Two-tailed p-value = 2 · P(Z > 3.1358) = 0.001714
Step 6: Reject H₀ since p = 0.001714 < 0.05 and |z| = 3.1358 > 1.9600. Strong statistical evidence confirms the two production lines have significantly different mean hourly output rates.

Assumptions of the Two Sample Z Test

There are 5 core statistical assumptions that validate the two sample z test:

1. Independent Random Sampling

The two samples must be randomly selected from two independent populations with no matching, pairing, or mutual influence between subjects.

2. Independent Observations Within Groups

Each observation within Sample 1 must be independent of other observations in Sample 1, and the same independence must hold within Sample 2.

3. Continuous Dependent Variable

The metric under evaluation must be measured on a continuous interval or ratio scale (such as weight, duration, output, or score).

4. Known Population Variances (σ₁ and σ₂)

Both population standard deviations must be known from extensive historical benchmarks. The values do not need to be equal (σ₁ may differ from σ₂).

5. Normality or Large Sample Sizes

The underlying populations must follow a normal distribution, or sample sizes must be sufficiently large (n₁ ≥ 30 and n₂ ≥ 30) for the Central Limit Theorem to ensure sampling normality.

Two Sample Z-Test vs. Two Sample T-Test vs. Paired T-Test

Select the appropriate statistical test based on your variance knowledge and sampling structure:

FeatureTwo Sample Z-TestTwo Sample T-TestPaired T-Test
Population Standard DeviationsKnown (σ₁, σ₂)Unknown (estimated from s₁, s₂)Unknown (estimated from s_d)
Sample RelationshipIndependent groupsIndependent groupsDependent / Paired (same subjects)
Reference DistributionStandard Normal (Z)Student's t (Welch df)Student's t (n − 1 df)
Sample Size RequirementTypically n₁, n₂ ≥ 30Valid for small and large nValid for small and large n
Standard Error Formula√(σ₁²/n₁ + σ₂²/n₂)√(s₁²/n₁ + s₂²/n₂)s_d / √n

Use a two-sample t-test, if population standard deviations are unknown. Use a paired t-test, if measurements are recorded on the same subjects before and after an intervention.

Two Sample Z Test for Means vs. Proportions

A two sample z test for means compares quantitative continuous averages, whereas a two proportion z test compares qualitative categorical success percentages.

Two Sample Z-Test for Means

Analyzes continuous variables such as hourly units, crop kilograms, or exam points.

Data: x̄₁, x̄₂, σ₁, σ₂
Test: H₀: μ₁ − μ₂ = 0
Two Proportion Z-Test

Analyzes binary outcomes such as conversion rates, click percentages, or pass rates.

Data: p̂₁, p̂₂, n₁, n₂
Test: H₀: p₁ − p₂ = 0

How to Run a Two Sample Z Test in R and Excel

Execute two sample z tests directly in statistical programming environments using these exact commands:

R Implementation
# Two Sample Z-Test with known sigma
x1_bar <- 102.4; s1 <- 6.0; n1 <- 50
x2_bar <- 98.7;  s2 <- 5.5; n2 <- 45
alpha  <- 0.05

# Standard error and z statistic
se <- sqrt((s1^2 / n1) + (s2^2 / n2))
z_stat <- (x1_bar - x2_bar) / se

# Two-tailed p-value and critical boundaries
p_val <- 2 * (1 - pnorm(abs(z_stat)))
crit_z <- qnorm(1 - alpha / 2)

cat(sprintf("Z: %.4f | P-value: %.6f | Crit Z: ±%.4f\n", z_stat, p_val, crit_z))
Microsoft Excel & Google Sheets
Combined Standard Error:=SQRT((sigma1^2 / n1) + (sigma2^2 / n2))
Z Statistic:=(mean1 - mean2 - delta0) / SE_CELL
Two-Tailed P-Value:=2 * (1 - NORM.S.DIST(ABS(Z_CELL), TRUE))
Two-Tailed Critical Value:=NORM.S.INV(1 - alpha / 2)

Frequently Asked Questions

What does a two sample z test calculator do?▼

A two sample z test calculator evaluates whether the difference between the averages of two independent populations is statistically significant when both population standard deviations are known. The tool computes the test statistic, p-value, critical bounds, confidence interval, and a full six-step hypothesis test solution.

When should I use a two sample z test instead of a t test?▼

Use a two sample z test when both population standard deviations (σ₁ and σ₂) are known constants from historical data. Use a two sample t test, if the population standard deviations are unknown and must be estimated from sample variances.

Do the two population standard deviations have to be equal?▼

No, the two population standard deviations do not have to be equal. The test statistic formula incorporates σ₁²/n₁ and σ₂²/n₂ independently, allowing Population 1 and Population 2 to have different known standard deviations.

Can the sample sizes n₁ and n₂ be different?▼

Yes, the sample sizes n₁ and n₂ can be different. The formula computes the standard error separately for each group, accommodating unequal sample sizes without bias.

Can I enter raw data into the calculator?▼

Yes, compute the sample mean and count for each group first from your raw data observations, then enter those summary values into the calculator. You must still provide the known population standard deviation for each population.

Is a two sample z test the same as a two proportion z test?▼

No, a two sample z test compares quantitative continuous means with known standard deviations, while a two proportion z test compares categorical binary rates or percentages.

What happens if the hypothesized difference is not zero?▼

Enter the non-zero value into the Δ₀ field, if testing whether the difference between means exceeds a specific threshold. The calculator subtracts Δ₀ from (x̄₁ − x̄₂) before dividing by the combined standard error.

William Davis

Created by William Davis

Last updated: October 24, 2026

Add to Google Preferred