EDA Report - GONZALES EJ

Download as pdf or txt
Download as pdf or txt
You are on page 1of 8

COLLEGE OF ENGINEERING

EJ H. GONZALES EN MATH 4 – ENGINEERING DATA ANALYSIS


BSEE 4A

LEARNING MODULE: Z-TEST

INTRODUCTION:

Z-Test is a statistical test that is conducted on data that approximately follows a normal
distribution. The z-test can be performed on one sample, two samples, or on proportions for
hypothesis testing. It checks if the means of two large samples are different or not when the
population variance is known.

A z-test can further be classified into left-tailed, right-tailed, and two-tailed hypothesis tests
depending upon the parameters of the data. In this article, we will learn more about the z-test, its
formula, the z-test statistic, and how to perform the test for different types of data using examples.

What is Z-TEST?

A z-test is a test that is used to check if the means of two populations are different or not
provided the data follows a normal distribution. For this purpose, the null hypothesis and the
alternative hypothesis must be set up and the value of the z-test statistic must be calculated. The
decision criterion is based on the z-critical value.

Z-TEST definition?

A z-test is conducted on a population that follows a normal distribution with independent


data points and has a sample size that is greater than or equal to 30. It is used to check whether
the means of two populations are equal to each other when the population variance is known. The
null hypothesis of a z-test can be rejected if the z-test statistic is statistically significant when
compared with the critical value.

Z-TEST Formula

The z-test formula compares the z-statistic with the z-critical value to test whether there is
a difference in the means of two populations. In hypothesis testing, the z-critical value divides the
distribution graph into the acceptance and the rejection regions. If the test statistic falls in the
rejection region then the null hypothesis can be rejected otherwise it cannot be rejected. The z-test
formula to set up the required hypothesis tests for a one sample and a two-sample z-test are given
below.
H0 = null hypothesis
𝒙 = mean of sample
μ0 = mean of population
σ = standard deviation of population
n = no. of observations

 One-Sample Z-TEST

A one-sample z-test is used to check if there is a difference between the sample mean and
the population mean when the population standard deviation is known. The formula for the z-test
statistic is given as follows:

1
COLLEGE OF ENGINEERING
𝒙− µ
𝒛= 𝝈
√𝒏
𝑿 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 is given as follows:

 Left Tailed Test:

Null Hypothesis: H0: μ = μ0 Alternate Hypothesis: H1: μ < μ0

Decision Criteria: If the z-statistic < z-critical value then reject the null hypothesis.

 Right Tailed Test:

Null Hypothesis: H0: μ = μ0 Alternate Hypothesis: H1: μ > μ0

Decision Criteria: If the z-statistic > z-critical value then reject the null hypothesis.

 Two Tailed Test:

Null Hypothesis: H0: μ = μ0 Alternate Hypothesis: H1: μ ≠ μ0

Decision Criteria: If the z-statistic > z-critical value then reject the null hypothesis.

 Two Sample Z-TEST

A two sample z-test is used to check if there is a difference between the means of two
samples. The z-test statistic formula is given as follows:
(𝒙𝟏 − 𝒙𝟐 ) − (μ1 − μ2 )
𝒛=
𝟐 𝟐
√( 𝝈𝟏 + 𝝈𝟐 )
𝒏 𝟏 𝒏𝟐
𝑥1 , µ1 , 𝜎12 are the sample mean, population mean and population variance respectively for
the first sample. 𝑥2 , µ2 , 𝜎22 are the sample mean, population mean and population variance
respectively for the second sample.

2
COLLEGE OF ENGINEERING
The two-sample z-test can be set up in the same way as the one-sample test. However,
this test will be used to compare the means of the two samples. For example, the null hypothesis
is given as H0: μ1=μ2.

Z-TABLE

3
COLLEGE OF ENGINEERING

Significance Level Type of Test Critical Value(s)

0.01 Two-Tailed ±2.576

0.01 Left Tail –2.326

0.01 Right Tail +2.326

0.05 Two-Tailed ±1.960

0.05 Left Tail +1.650

0.05 Right Tail –1.650

Type I or Type II Error Table

Reject H0 Do not reject Ho

H0 is true Type I Error Correct Decision

H0 is false Correct Decision Type II Error

 Type I error occurs if one rejects the null hypothesis when it is true.
 Type II error occurs if one does not reject the null hypothesis when it is false.

Z-TEST for Proportions

A z-test for proportions is used to check the difference in proportions. A z-test can either
be used for one proportion or two proportions. The formulas are given as follows.

One Proportion Z-TEST

A one proportion z test is used to check if the value of the observed proportion is different
from the value of the theoretical proportion. A one proportion z-test is used when there are two
groups and compares the value of an observed proportion to a theoretical one. The z-test statistic
for a one proportion z-test is given as follows:
𝒑 − 𝒑𝟎
𝒛=
√𝒑𝟎 (𝟏 − 𝒑𝟎 )
𝒏
Here, p is the observed value of the proportion, p0 is the theoretical proportion value and n
is the sample size.

The null hypothesis is that the two proportions are the same while the alternative
hypothesis is that they are not the same.

Two Proportion Z-TEST

A two proportion z-test is conducted on two proportions to check if they are the same or
not. When the proportions of two samples have to be compared then the two proportion z-test is
used. The test statistic formula is given as follows:
𝒑𝟏 − 𝒑𝟐 − 𝟎
𝒛=
𝟏 𝟏
√𝒑(𝟏 − 𝒑)(
𝒏𝟏 + 𝒏𝟐 )

4
COLLEGE OF ENGINEERING

𝒙𝟏 + 𝒙𝟐
Where p = ,
𝒏𝟏 + 𝒏𝟐
p1 is the proportion of sample 1 with sample size n1 and x1 number of trials.
p2 is the proportion of sample 2 with sample size n2 and x2 number of trials.

What is a Z Test in Statistics?

A z test in statistics is conducted on data that is normally distributed to test if the means of
two datasets are equal. It can be performed when the sample size is greater than 30 and the
population variance is known.

How to Calculate Z-TEST Statistic?

The most important step in calculating the z-test statistic is to interpret the problem
correctly. It is necessary to determine which tailed test needs to be conducted and what type of
test does the z-statistic belong to. Suppose a teacher claims that his section's students will score
higher than his colleague's section. The mean score is 22.1 for 60 students belonging to his section
with a standard deviation of 4.8. For his colleague's section, the mean score is 18.8 for 40 students
and the standard deviation is 8.1. Test his claim at α = 0.05. The steps to calculate the z-test
statistic are as follows:

 Identify the type of test. In this example, the means of two populations have to be
compared in one direction thus, the test is a right-tailed two-sample z-test.
 Set up the hypotheses. H0: μ1 = μ2, H1: μ1 > μ2.
 Find the critical value at the given alpha level using the z table. The critical value
is 1.645.
 Determine the z-test statistic using the appropriate formula. This is given by
(𝒙𝟏 − 𝒙𝟐 ) − (μ1 − μ2 )
𝒛=
𝟐 𝟐
√( 𝝈𝟏 + 𝝈𝟐 )
𝒏𝟏 𝒏𝟐
Substitute values in this equation. 𝑥1 = 22.1, σ1 = 4.8, n1 = 60, 𝑥1 = 18.8, σ2 =
8.1, n2 = 40 and μ1−μ2=0. Thus, z = 2.32
 Compare the critical value and test statistic to arrive at a conclusion. As 2.32 >
1.645 thus, the null hypothesis can be rejected. It can be concluded that there is
enough evidence to support the teacher's claim that the scores of students are
better in his class.

Z-TEST vs T-TEST

Both z-test and t-test are univariate tests used on the means of two datasets. The
differences between both tests are outlined in the table given below:

Z-TEST T-TEST

A z-test is a statistical test that is used to check A t-test is used to check if the means of two
if the means of two data sets are different when data sets are different when the population
the population variance is known. variance is not known.

The sample size is greater than or equal to 30. The sample size is lesser than 30.

5
COLLEGE OF ENGINEERING

The data follows a normal distribution. The data follows a student-t distribution.

The one-sample z test statistic is given 𝒙− µ


𝒙− µ The t test statistic is given as 𝒔 where s is
by 𝝈 √𝒏
√𝒏 the sample standard deviation

Important Notes on Z-TEST

 Z-test is a statistical test that is conducted on normally distributed data to check if


there is a difference in means of two data sets.
 The sample size should be greater than 30 and the population variance must be
known to perform a z-test.

 The one-sample z-test checks if there is a difference in the sample and population
mean,
 The two sample z-test checks if the means of two different groups are equal.

Examples on Z-TEST

Example: A teacher claims that the mean score of students in his class is greater than 82 with a
standard deviation of 20. If a sample of 81 students was selected with a mean score of 90 then
check if there is enough evidence to support this claim at a 0.05 significance level.

Solution: As the sample size is 81 and population standard deviation is known, this is an example
of a right-tailed one-sample z-test.

H0: μ = 82
H1: μ > 82

From the z-table the critical value at α = 1.645


𝒙− µ
𝒛= 𝝈
√𝒏
𝒙 = 90, μ = 82, n = 81, σ = 20
z = 3.6

As 3.6 > 1.645 thus, the null hypothesis is rejected and it is concluded that there is enough evidence
to support the teacher's claim.

Answer: Reject the null hypothesis

6
COLLEGE OF ENGINEERING
QUIZ:

I. TRUE OR FALSE
1. Type I error occurs if one does not reject the null hypothesis when it is true.
2. Type II error occurs if one rejects the null hypothesis when it is false.
3. The difference between z-test and t-test is that the sample size of z-test is < 30 and t-
test ≥ to 30.
II. IDENTIFYING WHETHER THE NULL HYPOTHESIS IS REJECTED OR NOT.
4. An online medicine shop claims that the mean delivery time for medicines is less than
120 minutes with a standard deviation of 30 minutes. Is there enough evidence to
support this claim at a 0.05 significance level if 49 orders were examined with a mean
of 100 minutes?
5. A company wants to improve the quality of products by reducing defects and
monitoring the efficiency of assembly lines. In assembly line A, there were 18 defects
reported out of 200 samples while in line B, 25 defects out of 600 samples were noted.
Is there a difference in the procedures at a 0.05 alpha level?

ANSWERS:

1. FALSE
2. FALSE
3. FALSE

Solution for number 4: As the sample size is 49 and population standard deviation is known, this
is an example of a left-tailed one-sample z test.

H0: μ = 120
H1: μ < 120

From the z table the critical value at α = -1.645. A negative sign is used as this is a left tailed test.
𝒙− µ
𝒛= 𝝈
√𝒏
𝟏𝟎𝟎 − 𝟏𝟐𝟎
𝒛=
𝟑𝟎
√𝟒𝟗
z = -4.667
𝒙 = 100, μ = 120, n = 49, σ = 30
z = -4.667

As -4.667 < -1.645 thus, the null hypothesis is rejected and it is concluded that there is enough
evidence to support the medicine shop's claim.

Answer: Reject the null hypothesis

Solution for number 5: This is an example of a two-tailed two proportion z test.

H0: The two proportions are the same.


H1: The two proportions are not the same.

As this is a two-tailed test the alpha level needs to be divided by 2 to get 0.025.

Using this, the critical value from the z table is 1.96.


n1 = 200, n2 = 600
p1 = 18 / 200 = 0.09
p2 = 25 / 600 = 0.0416

7
COLLEGE OF ENGINEERING
p = (18 + 25) / (200 + 600) = 0.0537
𝒑𝟏 −𝒑𝟐 −𝟎
𝒛= 𝟏 𝟏
√𝒑(𝟏−𝒑)(𝒏 + 𝒏 )
𝟏 𝟐
𝟎.𝟎𝟗−𝟎.𝟎𝟒𝟏𝟔−𝟎
𝒛= 𝟏 𝟏
√𝟎.𝟎𝟓𝟑𝟕(𝟏−𝟎.𝟎𝟓𝟑𝟕)( + )
𝟐𝟎𝟎 𝟔𝟎𝟎

z = 2.63
As 2.63 > 1.96 thus, the null hypothesis is rejected and it is concluded that there is a significant
difference between the two lines.

Answer: Reject the null hypothesis

REFERENCES:
https://www.cuemath.com/data/z-test/

https://www.investopedia.com/terms/z/z-
test.asp#:~:text=A%20z%2Dtest%20is%20a%20statistical%20test%20to%20det
ermine%20whether,result%20from%20the%20z%2Dtest

https://www.youtube.com/watch?v=xPhA0Qwx0CY

https://statisticsbyjim.com/hypothesis-testing/z-
test/?fbclid=IwAR1v4f2MwynnXcdRNkxJT5LAocBavD1t1l1vrwOIX91cX8NUf1IG
MFFwXew

https://www.slideshare.net/MuhammadAnas96/ztest-with-
examples?fbclid=IwAR1WtLhlFDiKdF2VfCCEHAqEpLveHHW6odlnTNU_SIpouL
pUmBpavPyHToI

https://www.ztable.net/wp-content/uploads/2018/11/positiveztable.png

You might also like