# Two Sample Z Hypothesis Test

• /
• Blog
• /
• Two Sample Z Hypothesis Test

A two-sample z-test is a statistical test used to compare the means of two different samples to determine if there is a significant difference between them. It is based on the assumption that both samples are drawn from normally distributed populations with equal variances.

## Steps in Two Sample Z Test

To conduct a two-sample z-test, the following steps are typically followed:

1. Specify the null and alternative hypotheses. The null hypothesis is usually that the means of the two samples are equal, while the alternative hypothesis is that the means are not equal.
2. Collect and summarize the data for both samples. Calculate the sample means and standard deviations for each sample.
3. Calculate the test statistic, which is the difference between the two sample means, divided by the standard error of the mean.
4. Determine the critical value of the test statistic based on the significance level (alpha) of the test.
5. Compare the calculated test statistic to the critical value to determine whether to reject or fail to reject the null hypothesis. If the calculated test statistic exceeds the critical value, the null hypothesis is rejected, and the alternative hypothesis is accepted.

## Conditions for Z Test

To conduct a valid two-sample z-test, the following conditions must be met:

1. Both samples must be drawn randomly from their respective populations.
2. Each observation in each sample must be independent of the others.
1. The sampling must be done with replacement, OR
2. If sampling without replacement, the sample size must be less than 10% of the population.
3. The populations must approximate a normal distribution.
4. The population standard deviations must be known, or each sample size must be large (30 or more).

## Two Sample Z Test:

Two Sample Z Test (Online Calculator)

### Sample 2

 function performTwoSampleZTest() { const tailType = document.getElementById('tailType').value; const mean1 = parseFloat(document.getElementById('mean1').value); const stdDev1 = parseFloat(document.getElementById('stdDev1').value); const sampleSize1 = parseInt(document.getElementById('sampleSize1').value); const mean2 = parseFloat(document.getElementById('mean2').value); const stdDev2 = parseFloat(document.getElementById('stdDev2').value); const sampleSize2 = parseInt(document.getElementById('sampleSize2').value); if ([mean1, stdDev1, sampleSize1, mean2, stdDev2, sampleSize2].some(isNaN)) { alert('Please enter valid numbers in all fields.'); return; } const pooledStdDev = Math.sqrt(((stdDev1 ** 2) / sampleSize1) + ((stdDev2 ** 2) / sampleSize2)); const zScore = (mean1 - mean2) / pooledStdDev; let pValue; if (tailType === 'two-tailed') { pValue = 2 * (1 - jStat.normal.cdf(Math.abs(zScore), 0, 1)); } else { // one-tailed pValue = 1 - jStat.normal.cdf(zScore, 0, 1); } document.getElementById('resultText').innerHTML = Z-Score: ${zScore.toFixed(4)}, P-Value:${pValue.toFixed(4)}; } 

## Typical Null and Alternate Hypotheses in Two-Sample Z Test

a) Two Tail Test:

In a two-sample z-test, the null hypothesis is that there is no difference between the means of the two samples. This can be expressed as:

H0: μ1 = μ2

where μ1 is the mean of the first sample and μ2 is the mean of the second sample.

The alternate hypothesis is the opposite of the null hypothesis and is that there is a difference between the means of the two samples. This can be expressed as:

Ha: μ1 ≠ μ2

b) Left Tail Test:

A left-tailed hypothesis is one in which the mean of the first sample is less than the mean of the second sample. This can be expressed as:

H0: μ1 >= μ2

Ha: μ1 < μ2

c) Right Tail Test:

A right-tailed hypothesis is one in which the mean of the first sample is greater than the mean of the second sample. This can be expressed as:

H0: μ1 <= μ2

Ha: μ1 > μ2

## Calculating Test Statistic

The z-score represents the number of standard deviations that the difference between the two sample means is from zero. It is used to determine whether the difference between the two sample means is statistically significant.

The formula for calculating the z-score in a two-sample z-test is as follows:

$$\LARGE{z = \frac{\bar{x}_1 - \bar{x}_2}{\sqrt{\frac{\sigma_1^2}{n_1} + \frac{\sigma_2^2}{n_2}}}}$$

where $$\bar{x}_1$$ and $$\bar{x}_2$$ are the sample means, $$\sigma_1^2$$ and $$\sigma_2^2$$ are the sample variances, and $$n_1$$ and $$n_2$$ are the sample sizes.

## Typical Critical Values

The critical values for the z-score in a two-sample z-test depend on whether the test is a one-tail or two-tail test.

For a one-tail test, the critical value is determined based on the tail of the distribution in which the alternative hypothesis is located. For example, if the alternative hypothesis is that the mean of the first sample is greater than the mean of the second sample, the critical value would be the value that corresponds to the upper tail of the distribution.

For a two-tail test, the critical value is determined based on the significance level of the test and the total area of both tails of the distribution. For example, if the significance level is 0.05 and the test is two-tailed, the critical value would be the value that corresponds to an area of 0.05 in both tails of the distribution (or 0.025 area in one tail, as the normal distribution is symmetric).

The most common critical values for the z-score in a two-sample z-test are as follows:

• For a two-tail test with a significance level of 0.05, the critical value is 1.64.
• For a two-tail test with a significance level of 0.01, the critical value is 2.33.
• For a two-tail test with a significance level of 0.001, the critical value is 3.09.
• For a two-tail test with a significance level of 0.05, the critical value is 1.96.
• For a two-tail test with a significance level of 0.01, the critical value is 2.58.
• For a two-tail test with a significance level of 0.001, the critical value is 3.29.

These critical values are based on the standard normal distribution and are used to determine whether the calculated z-score is statistically significant. If the calculated z-score is greater than the critical value, the null hypothesis is rejected, and the alternative hypothesis is accepted.

You can find the critical values using a Normal Distribution table or software such as Excel. The formula to find out this value in Excel is =NORM.S.INV(alpha) for the one-tail test and =NORM.S.INV(alpha/2) for the two-tail test. This provides the critical z value for the left tail.

Similar Posts:

March 26, 2023

## Taguchi Loss Function

Taguchi Loss Function

October 23, 2022

## Six Sigma Training Courses – Online or Classroom

Six Sigma Training Courses – Online or Classroom

January 21, 2018

## Minitab 17 Tutorial

Minitab 17 Tutorial

49 Courses on SALE!