📢
Admissions Open for August 2026 Batch | Free Career Counselling | Limited Scholarships
Register Now →

Learning Guides

Hypothesis Testing Using Z-Test: Complete Guide

Quick answer: Learn the Z-test for hypothesis testing, including when to use it, the null and alternative hypothesis, calculating the Z-statistic, and interpreting the p-value.

What is a Z-Test?

A Z-test is a statistical hypothesis test used to determine whether a sample mean differs significantly from a known population mean, or whether two sample means differ from each other, when the population standard deviation is known and the sample size is reasonably large, typically above 30.

Null and Alternative Hypothesis

The null hypothesis (H0) usually states there is no real difference. The alternative hypothesis (H1) states that a real difference does exist. The test calculates how likely the observed data would be if the null hypothesis were actually true.

The Z-Statistic Formula

Z = (sample_mean - population_mean) / (population_std_dev / sqrt(sample_size))

A Worked Example

Suppose a training company claims its average course completion time is 40 hours with a known population standard deviation of 5 hours. A sample of 50 recent students completed the course in an average of 42 hours. Is this difference statistically significant?

import numpy as np
from scipy import stats

sample_mean = 42
population_mean = 40
population_std = 5
n = 50

z_statistic = (sample_mean - population_mean) / (population_std / np.sqrt(n))
p_value = 2 * (1 - stats.norm.cdf(abs(z_statistic)))

print(f"Z-statistic: {z_statistic:.2f}, p-value: {p_value:.4f}")

Interpreting the Result

If the resulting p-value is below the chosen significance level, commonly 0.05, the difference is considered statistically significant, meaning it is unlikely to have occurred by random chance alone, and the null hypothesis is rejected.

One-Tailed vs Two-Tailed Tests

A two-tailed test checks whether the sample mean differs from the population mean in either direction. A one-tailed test checks for a difference in one specific direction only, such as testing whether completion time is specifically higher, not just different. The choice depends on the actual business or research question being asked.

Z-Test vs T-Test

Z-testT-test
Population standard deviation is knownPopulation standard deviation is unknown, estimated from the sample
Typically used with large samples (n > 30)Commonly used with smaller samples

In practice, the population standard deviation is rarely known with certainty, which is why the t-test is used far more often than the Z-test in real world analysis.

Common Interview Questions

When would you use a Z-test instead of a t-test?

When the population standard deviation is genuinely known and the sample size is reasonably large, conditions that are actually fairly uncommon in most real world business analysis.

What does a p-value below 0.05 mean in a Z-test?

It means the observed difference is unlikely to have occurred by random chance alone under the null hypothesis, leading to rejection of the null hypothesis at the standard 5 percent significance level.

FAQ

Frequently Asked Questions

What is a Z-test used for?

It tests whether a sample mean differs significantly from a known population mean, when the population standard deviation is known and the sample size is reasonably large.

What is the difference between a Z-test and a t-test?

A Z-test requires a known population standard deviation and is used with larger samples. A t-test is used when the population standard deviation is unknown and estimated from the sample, which is far more common in practice.

What does the p-value tell you in a Z-test?

It indicates the probability of observing a difference this large or larger if the null hypothesis were true. A p-value below 0.05 typically leads to rejecting the null hypothesis.

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

A two-tailed test checks for a difference in either direction. A one-tailed test checks for a difference in one specific direction only, based on the actual question being asked.

Want This Mapped to Your Own Background?

A free counselling session will tell you which path fits, and will tell you honestly if none of ours does.

Book Free Career Counselling

Keep Reading

Related Articles