You are on page 1of 7

Lanka jaswanth

19BIT0061

Experiment No.:04
Z-Test for: Single Proportion, Single Mean,
Difference of
Proportionsand
Difference of Means
Experiment Date: 11-

SEP-2020 Problem’s:

1. Experience has shown that 20% of a manufactured product is of


top quality. In one day’s production of 400 articles, only 50 are of
top quality. Write down the R programming code to test whether
the production of the day chosen is a representative sample at 95%
confidencelevel.

2. A sample of 900 items is found to have a mean of 3.47 cm. Write


down the R programming code to test whether it can be reasonably
regarded as a simple sample from a population with mean 3.23 cm
and SD 2.31 cm at 99% level of confidence.

3. Before an increase in excise duty on tea, 800 people out of a


sample of 1000 were consumers of tea. After the increase in duty,
800 people were consumers of tea in a sample of 1200 persons.
Write down the R programming code to test whether the
significant decrease in the consumption of tea after the increase in
duty at 1 % level ofsignificance.

4. The average mark scored by 32 boys is 72 with a standard


deviation of 8, while that for 36 girls is 70 with a standard deviation
of 6. Write down the R programming code to test whether the boys
are performing better than girls on the basis of average mark at 5 %
level ofsignificance
R.COD > print("H1:=p
E: !=P")
> #Z-Test for singleproportion [1] "H1 :=p!
> print("H0 =P"
:=p=P") [1] > alpha=0.05
"H0:=p=P" > ZTab=qnor
m(1-alpha)
> ZTab - > alpha=0.01
[1]1.644 3.7 > ZTab=qnor
854 5 m(1-alpha)
> P=20/ > if(abs(ZCal)<abs(ZTab)){ > ZTab
100 + print("H0 is accepted and H1 is [1] 2.326348
> n=400 rejected") > Mu=3.23
> p=50/ + }else{ > Sigma=2.3
400 + print("H0 is rejected and H1 is 1
> ZCal= accepted") > n=900
(p- +} > x0=3.47
P)/sqrt [1] "H0 is rejected and H1 is > ZCal=(x0-
(P*(1- accepted" Mu)/
P)/n) (Sigma/sqrt
> (n))
Z > ZCal
C > #Z-Test for singleMean [1] 3.116883
a > print("H0 :=
l x0=Mu") [1]
[ "H0 :=x0=Mu"
1 > print("H1 := x0!
] =Mu") [1] "H1
:=x0!=Mu"
> if(abs(ZCal)<abs(ZTab)){ "
+ print("H0 is accepted and H1 is H
rejected") 1
+ }else{
+ print("H0 is rejected and H1 is :
accepted") =
+} p
[1] "H0 is rejected and H1 isaccepted" 1
!
=
p
2
"
> #Z-Test for Difference ofproportions > alph
> print("H0 := a=0.
p1=p2") [1] 01
> ZTa
"H0 :=p1=p2"
> print("H1 := b=qn
p1!=p2") [1] orm(
1-alpha) + }else{
> ZTab +
[1] 2.326348 print("
> n1=1000 H0 is
> n2=1200 rejecte
> p1=800/1000 d and
> p2=800/1200 H1 is
> P=((n1*p1)+(n2*p2))/(n1+n2) accept
> ZCal=(p1-p2)/sqrt(P*(1- ed")
P)*((1/n1)+(1/n2))) +}
> ZCal [1] "H0 is
[1] 6.992059 rejecte
> if(abs(ZCal)<abs(ZTab)) d and
+{ H1 is
+ print("H0 is accepted and H1 is accept
rejected") ed"
rejecte
> #Z-Test for Difference ofMeans d")
> print("H0 := + }else{
x1=x2") [1] +
"H0 :=x1=x2" print("
> print("H1 := H0 is
x1!=x2") [1] rejecte
"H1 :=x1!=x2" d and
> alpha=0.05 H1 is
> ZTab=qnorm(1-alpha) accept
> ZTab ed")
[1] 1.644854 +}
> n1=32 [1] "H0 is
> n2=36 accept
> x1=72 ed and
> x2=70 H1 is
> s1=8 rejecte
> s2=6 d"
> ZCal=(x1-x2)/sqrt(((s1^2)/n1)+
((s2^2)/n2))
> ZCal
[1] 1.154701
> if(abs(ZCal)<abs(ZTab)){
+ print("H0 is accepted and H1 is
RESULT:
ZCal ZTab PrintResult

# Z-Test for single proportion:1.644854 -3.75 "H0 is rejected and H1 is accepted" #Z-
Test for single Mean : 2.326348 3.116883 "H0 is rejected and H1 is accepted" #Z-Test
for Difference : 2.326348 6.992059 "H0 is rejected and H1 is accepted"
ofproportions
#Z-Test for Difference : 1.644854 1.154701 "H0 is accepted and H1 is rejected"
ofMeans

PROOFS:
**THANK YOU**

You might also like