Z Test
2026-02-28 10:24 Diff

Z Test Formula

The z-test formula compares the z-statistic with the z-critical value to determine if there is a difference between the means of two populations. In hypothesis testing, the z-critical value separates the distribution into acceptance and rejection regions. If the test statistic falls in the rejection region, the null hypothesis is rejected; otherwise, it is not rejected.

The formulas used to set up hypothesis tests for both one-sample and two-sample z tests are given as:

One-Sample Z Test

A one-sample z test is used to determine whether the sample mean differs significantly from the population mean when the population standard deviation is known.

The formula for calculating the z-test statistic is:

\(z = \frac{\overline{x} - \mu}{\frac{\sigma}{\sqrt{n}}}\)

Where x is the sample mean, μ is the population mean, σ is the population standard deviation, and n is the sample size.

The algorithm to set a one-sample z test based on the z test statistic can be given as:

Left-Tailed Test:

Null Hypothesis: \(H_0 : μ =μ_0\)
Alternate Hypothesis: \(H_1:μ<μ_0\)
The decision criterion is to reject the null hypothesis if the z statistic is less than the z critical value.

Right-Tailed Test:

Null Hypothesis: \(H_0: μ = μ_0\)
Alternate Hypothesis: \(H_1: μ > μ_0\)
The decision criterion is to reject the null hypothesis if the z statistic is greater than the z critical value.

Two-Tailed Test:

Null Hypothesis: H0 : μ = μ0
Alternate Hypothesis: \(H_1 : μ ≠ μ_0\)
The decision criterion is to reject the null hypothesis if the z statistic is greater than the z critical value.

Two-Sample Z Test

A two-sample z test is a statistical method used to determine whether there is a significant difference between the means of two independent samples. It checks whether the averages of two groups differ, assuming the population variances are known and the samples are drawn from normally distributed populations.

The z test statistic formula is expressed as:

\(z = \frac{\left( \bar{x}_1 - \bar{x}_2 \right) - \left( \mu_1 - \mu_2 \right)} {\sqrt{\frac{\sigma_1^2}{n_1} + \frac{\sigma_2^2}{n_2}}} \)

Where \(\bar{x}_1, μ_1, \sigma_1^2\) are the sample mean, population mean and population variance respectively for the first sample. Similarly, \(\bar{x}_2, μ_2, \sigma_2^2\) are the sample mean, population mean, and population variance of the second sample.

The two-sample z test is similar to the one-sample test but is used to compare the means of two different samples. For instance, the null hypothesis can be stated as, \(H_0: μ_1 = μ_2\), meaning the means of the two populations are equal.