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:

**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.**Collect and summarize the data for both samples.**Calculate the sample means and standard deviations for each sample.**Calculate the test statistic,**which is the difference between the two sample means, divided by the standard error of the mean.- Determine the
**critical value of the test statistic**based on the significance level (alpha) of the test. - 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:

- Both samples must be
**drawn randomly**from their respective populations. - Each observation in each sample must be
**independent of the others.** - The populations must approximate a
**normal distribution.** - 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 1

### Sample 2

## 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.