You are on page 1of 27

LAB 6 - One sample z-test

S. Devi Yamini

February 22, 2023

Lab 6 February 22, 2023 1 / 14


Aim:
To test the hypothesis for Large Samples using one-sample Z-test.

Lab 6 February 22, 2023 2 / 14


Aim:
To test the hypothesis for Large Samples using one-sample Z-test.

Test for significance of single mean


(i) Left tail or Lower tail:

H0 : µ = µ0 , H1 : µ < µ0
x̄ −µ
Test statistic: Z = σ
√ follows standard normal distribution.
n

Reject H0 if Cal z < −zα

Lab 6 February 22, 2023 2 / 14


Problem 1
Suppose the manufacturer claims that the mean lifetime of a light
bulb is less than 10,000 hours. In a sample of 30 light bulbs, it was
found that they only last 9,900 hours on an average. Assume the
population standard deviation is 120 hours. At 0.05 significance
level, test the claim by the manufacturer?

Lab 6 February 22, 2023 3 / 14


Problem 1
Suppose the manufacturer claims that the mean lifetime of a light
bulb is less than 10,000 hours. In a sample of 30 light bulbs, it was
found that they only last 9,900 hours on an average. Assume the
population standard deviation is 120 hours. At 0.05 significance
level, test the claim by the manufacturer?
Given n = 30, x̄ = 9900, σ = 120, α = 0.05
H0 : µ = 10, 000 against H1 : µ < 10, 000

Lab 6 February 22, 2023 3 / 14


Problem 1
Suppose the manufacturer claims that the mean lifetime of a light
bulb is less than 10,000 hours. In a sample of 30 light bulbs, it was
found that they only last 9,900 hours on an average. Assume the
population standard deviation is 120 hours. At 0.05 significance
level, test the claim by the manufacturer?
Given n = 30, x̄ = 9900, σ = 120, α = 0.05
H0 : µ = 10, 000 against H1 : µ < 10, 000

R-code
xbar=9900
mu0=10000
sigma=120
n=30
z=(xbar-mu0)/(sigma/sqrt(n))
z
[1] -4.564355
Lab 6 February 22, 2023 3 / 14
Problem 1

R code
alpha=0.05
zalpha=qnorm(alpha)
[1] -1.644854

Lab 6 February 22, 2023 4 / 14


Problem 1

R code
alpha=0.05
zalpha=qnorm(alpha)
[1] -1.644854
if (z < zalpha) print("Reject H0 ") else print("Accept H0 ")
[1] "Reject H0 "

Interpretation
The test statistic -4.5644 is less than the critical value -1.644854.
So, we reject the null hypothesis. Hence, at 5% significance level,
we accept the claim that the mean lifetime of a light bulb is less
than 10,000 hours.

Lab 6 February 22, 2023 4 / 14


Test for significance of single mean

(ii) Right tail or Upper tail:

H0 : µ = µ0 , H1 = µ > µ0
x̄ −µ
Test statistic: Z = σ
√ follows standard normal distribution.
n

Reject H0 if Cal z > zα

Lab 6 February 22, 2023 5 / 14


Problem 2
Suppose the food label on a cookie bag states that there is at least 2
grams of saturated fat in a single cookie. In a sample of 35 cookies,
it is found that the mean amount of saturated fat per cookie is 2.1
grams. Assume that the population standard deviation is 0.25
grams. At 0.05 significance level, test the claim on food label?

Lab 6 February 22, 2023 6 / 14


Problem 2
Suppose the food label on a cookie bag states that there is at least 2
grams of saturated fat in a single cookie. In a sample of 35 cookies,
it is found that the mean amount of saturated fat per cookie is 2.1
grams. Assume that the population standard deviation is 0.25
grams. At 0.05 significance level, test the claim on food label?
Given n = 35, x̄ = 2.1, σ = 0.25, α = 0.05
H0 : µ = 2 against H1 : µ > 2

Lab 6 February 22, 2023 6 / 14


Problem 2
Suppose the food label on a cookie bag states that there is at least 2
grams of saturated fat in a single cookie. In a sample of 35 cookies,
it is found that the mean amount of saturated fat per cookie is 2.1
grams. Assume that the population standard deviation is 0.25
grams. At 0.05 significance level, test the claim on food label?
Given n = 35, x̄ = 2.1, σ = 0.25, α = 0.05
H0 : µ = 2 against H1 : µ > 2

R-code
xbar=2.1
mu0=2
sigma=0.25
n=35
z=(xbar-mu0)/(sigma/sqrt(n))
z
[1] 2.366432
Lab 6 February 22, 2023 6 / 14
Problem 2

R code
alpha=0.05
zalpha=qnorm(1-alpha)
[1] 1.644854

Lab 6 February 22, 2023 7 / 14


Problem 2

R code
alpha=0.05
zalpha=qnorm(1-alpha)
[1] 1.644854
if (z > zalpha) print("Reject H0 ") else print("Accept H0 ")
[1] "Reject H0 "

Interpretation
The test statistic 2.3664 is greater than the critical value 1.644854.
So, we reject the null hypothesis. Hence, at 5% significance level,
we accept the claim that there is at least 2 grams of saturated fat in
a cookie.

Lab 6 February 22, 2023 7 / 14


Test for significance of single mean

(iii) Two-tailed test:

H0 : µ = µ0 , H1 = µ ̸= µ0
x̄ −µ
Test statistic: Z = σ
√ follows standard normal distribution.
n

Reject H0 if Cal z < −z α or Cal z > z α


2 2

Lab 6 February 22, 2023 8 / 14


Problem 3
Suppose the mean weight of King Penguins found in an Antarctic
colony last year was 15.4 kg. In a sample of 35 penguins same time
this year in the same colony, the mean penguin weight is 14.6 kg.
Assume the population standard deviation is 2.5 kg. At 0.05
significance level, test the null hypothesis that the mean penguin
weight does not differ from last year?

Lab 6 February 22, 2023 9 / 14


Problem 3
Suppose the mean weight of King Penguins found in an Antarctic
colony last year was 15.4 kg. In a sample of 35 penguins same time
this year in the same colony, the mean penguin weight is 14.6 kg.
Assume the population standard deviation is 2.5 kg. At 0.05
significance level, test the null hypothesis that the mean penguin
weight does not differ from last year?
Given n = 35, x̄ = 14.6, σ = 2.5, α = 0.05
H0 : µ = 15.4 against H1 : µ ̸= 15.4

Lab 6 February 22, 2023 9 / 14


Problem 3
Suppose the mean weight of King Penguins found in an Antarctic
colony last year was 15.4 kg. In a sample of 35 penguins same time
this year in the same colony, the mean penguin weight is 14.6 kg.
Assume the population standard deviation is 2.5 kg. At 0.05
significance level, test the null hypothesis that the mean penguin
weight does not differ from last year?
Given n = 35, x̄ = 14.6, σ = 2.5, α = 0.05
H0 : µ = 15.4 against H1 : µ ̸= 15.4
R-code
xbar=14.6
mu0=15.4
sigma=2.5
n=35
z=(xbar-mu0)/(sigma/sqrt(n))
z
[1] -1.893146
Lab 6 February 22, 2023 9 / 14
Problem 3

R code
alpha=0.05
zalpha=qnorm(alpha/2)
[1] -1.959964

Lab 6 February 22, 2023 10 / 14


Problem 3

R code
alpha=0.05
zalpha=qnorm(alpha/2)
[1] -1.959964
if (abs(z)< abs(zalpha)) print("Accept H0") else print("Reject H0")

Interpretation
The test statistic -1.8931 lies between the critical values -1.96 and
1.96. So, we accept the null hypothesis. Hence, at 5% significance
level, we accept the claim the null hypothesis that the mean
penguin weight does not differ from the last year.

Lab 6 February 22, 2023 10 / 14


Test for Population proportion

(i) Left tail or Lower tail test:

H0 : P = P0 , H1 = P ≤ P0
p −P
Test statistic: z = q PQ
follows standard normal distribution.
n

Reject H0 if Cal z < −zα

Lab 6 February 22, 2023 11 / 14


Test for Population proportion

(i) Left tail or Lower tail test:

H0 : P = P0 , H1 = P ≤ P0
p −P
Test statistic: z = q PQ
follows standard normal distribution.
n

Reject H0 if Cal z < −zα

Problem 1
Suppose 60 % of citizens voted in last election. 85 out of 148 people
in a telephone survey said that they voted in the current election. A
0.05 significance level, test the hypothesis that the proportion of
voters in the population is below 60 % this year?

Lab 6 February 22, 2023 11 / 14


Test for population proportion

H0 : P = 0.60 against H1 : P < 0.6 (left tailed)


85
p = 148 = 0.5743

Lab 6 February 22, 2023 12 / 14


Test for population proportion

H0 : P = 0.60 against H1 : P < 0.6 (left tailed)


85
p = 148 = 0.5743

R code
p=85/148
P=60/100
n=148
Q=1-P
z=(p-P)/sqrt(P x Q/n)
z
[1] -0.6375983

Lab 6 February 22, 2023 12 / 14


R code

alpha=0.05
zalpha=qnorm(alpha)
[1] -1.644854

Lab 6 February 22, 2023 13 / 14


R code

alpha=0.05
zalpha=qnorm(alpha)
[1] -1.644854
if (z < zalpha) print("Reject H0") else print("Accept H0")
[1] "Accept H0"

Interpretation
The test statistic -0.6376 is more than the critical value -1.644854.
So, we accept the null hypothesis. Hence, at 5% significance level,
there is no evidence to prove that the proportion of voters in the
population is below 60% this year.

Lab 6 February 22, 2023 13 / 14


Assignment

1. Suppose that 12% of apples harvested in an orchard last year


was rotten. 30 out of 214 apples in a harvest sample this year turns
out to be rotten. At .05 significance level, test the null hypothesis
that the proportion of rotten apples in harvest stays above 12% this
year? ( A problem on right tail)

Lab 6 February 22, 2023 14 / 14

You might also like