You are on page 1of 12

MAT2001-Statistics for Engineers

Embedded Lab- R Statistical Software


WINTER SEMESTER-2018~2019 L37+L38 SLOT

E-RECORD

Experiment No.:5—

Submitted By

Name of the Student: Sidharth Kumar Jha

Reg. No.: 18BEE0007


M.Tech./B.Tech.(Branch)-I/II/III Year Name of the School

DEPARTMENT OF MATHEMATICS

SCHOOL OF ADVANCED SCIENCES

VELLORE INSTITUTE OF TECHNOLOGY

VELLORE-632014

TAMIL NADU INDIA

Date: Day-Month-Year

12-3-2019
Name:- SIDHARTH KUMAR JHA

Reg No.:-18BEE0007

Experiment No:5
Title of the Experiment: t-test for single mean,
Difference of means, paired t-test and F-test.
Experiment Date: 12-03-2019

Problem no: 1

1. Aim of the problem: Write the R- programming


to test whether data support the assumption of a
population mean IQ of 100 at 5% level of
significance.

2.1: Inputs for the above code:


10 boys IQs: 70,120,110,101,88,83,95,98,107,100
2.2: code for the above problem:
#t-test for single mean
Print(“H0 := x0=Mu”)
Print(“H1 :=x0!=Mu”)
Alpha=0.05
Mu=100
n=10
x=c(70,120,110,101,88,83,95,98,107,100)
x0=mean(x)
s=sqrt(var(x))
ttab=qt((1-alpha),(n-1))
ttab
tcal=(x0-Mu)/(s/sqrt(n-1))
tcal
if(abs(tcal)<abs(ttab)){
print(“H0 is accepted and H1 is rejected”)
} else{
Print(“H0 is rejected and H1 is accepted”)
}
t.test(x,mu=Mu)
2.3: Output for the above code:
ttab=1.833113
tcal=-0.5885024
H0 is accepted and H1 is rejected that means true
mean is equal to 100.
Problem no:2

1 . Aim of the problem: Write the R- Programming


code to test whether the soldiers are shorter than
the sailors on the basis of average height.

2.1 : Inputs for the above problem:


n1=8, n2=6, Mh1=166.9 cm, Mh2=170.3 cm,
Sd1=8.29 cm, Sd2=8.5cm
2.2 : code for the above problem:
#t-test for the difference of means
Print(“H0 := x1=x2”)
Print(“H1 := x1!=x2”)
Alpha=0.01
n1=8
n2=6
x1=166.9
x2=170.3
s1=8.29
s2=8.5
Sigma=sqrt(((n1*s1^2)+(n2*s2^2))/(n1+n2-2))
ttab=qt((1-alpha),(n1+n2-2))
ttab
tcal=(x1-x2)/(Sigma*sqrt((1/n1)+(1/n2)))
tcal
if(abs(tcal)<abs(ttab)){
print(“H0 is accepted and H1 is rejected”)
} else{
Print(“H0 is rejected and H1 is accepted”)
2.3 Output for the above problem:
ttab=2.680998
tcal=-0.695401
H0 is accepted and H1 is rejected that means
there is no significant difference between the
means.
Problem no:3

1 . Aim of the problem: Write the R-Programming


code to indicate the students have benefited by
coaching at 5% level of significance.
2.1: Inputs for the above problem:
Test1 19 23 16 24 17 18 20 18 21 19 20
Test2 17 24 20 24 20 22 20 20 18 22 19

2.2: Code for the above problem: Name: P.


Karthik Abhishek
#paired t-test for the difference of means Reg
no:18BEE0156
Print(“H0 := x1=x2”)
Print(“H1 :=x1!=x2”)
Alpha=0.05
s1-s2
d=mean(D)
n=length(D)
s=sqrt(var(D))
ttab=qt((1-alpha),(n-1))
ttab
tcal=d/(s/sqrt(n-1))
tcal if(abs(tcal)<abs(ttab)){
print(“H0 is accepted and H1 is rejected”)
} else {
Print(“H0 is rejected and H1 is accepted”)
}
2.3: Output for the above problem:
Ttab=1.812461
Tcal=-1.313064
H0 is accepted and H1 is rejected that means

Students are benefit for the coaching.


Problem no:4
1. Aim of the above problem:
Write the R-Programming code to test whether
the two populations are having same variances at
5% level of significance.
2.1: Inputs for the above problem:
Sample 21 24 25 26 27 25
1
Sample 22 27 28 30 31 36
2

2.2: code for the above problem: Name: P. Karthik


Abhishek
#F- test for the difference of variances Reg
no:18BEE0156
Print(“H0 :=s1=s2”)
Print(“H1 :=s1!=s2”)
Alpha=0.05
s1=c(21,24,25,26,27)
s2=c(22,27,28,30,31,36)
n1=length(s1)
n2=length(s2)
x1=mean(s1)
x2=mean(s2)
s1=sqrt(var(s1))
s2=sqrt(var(s2))
Var 1=(n1/(n1-1))*(s1^2)
Var 2=(n2/(n2-1))*(s2^2)
FTab=qf((1-alpha),(n1-1),(n2-1))
FTab
if(Var 1> Var2){
FCal=Var 1/Var 2
} else {
FCal=Var 2/Var 1
}
FCal
If(abs(FCal)<abs(FTab)){
Print(“H0 is accepted and H1 is rejected”)
} else {
Print(“H0 is rejected and H1 is accepted”)
}
2.3: Ouput for the above code: FTab=5.192168
FCal=3.912453
H0 is accepted and H1 is rejected that means
variances are same at 5% level of significance.
3: Proof for the output expectation in Lab hours:

You might also like