In the first article about z-test, we showed how the two-tailed test works. It is also possible to construct an one-tailed test. The one-tailed test differs with a sign of alternative hypothesis. The two-tail test had the inequality sign () in the alternative hypothesis formula. For an one-tailed test, there are two options:

- left-tailed test which has less than () sign,
- right-tailed test which has greater than () sign.

**The formula for the test statistics stay the same, whereas the critical region is now different.** It lays only in one side of the axis. More specifically, the whole critical region is in the left side for the left-tailed test or in the right side for the right-tailed test (pretty straightforward if you ask me). The computation of the p-value also changes.

## Left-tailed test

Let’s start with the left-tailed test. Our assignment stays with a small modification. We will assume that the machine does not allow to set the length of the component to more than 190 mm, it can be set to shorter length though. So we only need to check if the components are in average shorter, or not. We now have a new set of 20 observations.

189.3828 | 188.1783 | 189.2116 | 190.6886 | 190.0598 | 188.4774 | 189.5478 | 189.1187 | 188.5021 | 189.9077 | 191.3365 | 190.1061 | 189.76 | 189.1427 | 189.8124 | 189.1332 | 190.7368 | 189.4031 | 190.099 | 189.5483 |

As we said, **the null hypothesis stays** and the alternative has sign, so:

- ,
- .

The critical region consists only of one part now, as you can see at the figure below. Because the area under the probability density function must still equal to the significance level, the border values are closer to zero. You can compare the figure with the figure for two-tailed test.

The formula for the critical region is

Please note that is not divided by 2. We will keep the level of significance on 5 % so the critical region for our example is

We can get the value – 1.6449 from a statistical table. Please note we use the value for 0.95 because the normal distribution is symmetric. We only add the minus sign.

The value of the statistics is:

and it lies in the critical region so we reject the null hypothesis for . The conclusion of the test is that the expected value of the length of the component is lower than 190 mm, i.e. the machine was set incorrectly.

## Right-tailed test

Now we will go through the last variant which is called right-tailed test. We will work with the same example with a one modification: We assume the machine could not be set to produce shorter components than 190 mm but it set be by mistake set to produce longer one. We will use a new sample of data.

189.7755 | 189.2872 | 189.8255 | 189.4385 | 190.1141 | 189.4514 | 190.7601 | 189.7654 | 190.0965 | 190.0603 | 189.9051 | 188.8833 | 190.8449 | 190.2563 | 190.8725 | 189.3535 | 191.1673 | 189.1358 | 189.3755 | 190.7177 |

The new hypotheses are:

- ,
- .

It is not surprising that the critical region now lies in the right part of the x axis.

The formula for the critical region is

and if we stay on we get

The value of the statistics is now

and it does not lies in the critical region so we do not reject the null hypothesis for .