You are on page 1of 9

ASSIGNMENT 5

Lanka jaswanth
19BIT0061.

1. A random sample of 10 boys with the following IQs: 70, 120, 110, 101, 88, 83, 95, 98,
107,and100.WritedowntheRprogrammingcodetotestwhetherthedatasupportthe
assumption of a population mean IQ of 100 at 5 % level ofsignificance.

2. The mean height and the standard deviation height of 8 randomly chosen soldiersare
166.9 cm and 8.29 cm respectively. The corresponding values of 6 randomly chosen sailors
are 170.3 cm and 8.50 cm respectively. Write down the R programming code to test
whether the soldiers are shorter than the sailors on the basis of average height.

3. The following data relate to the marks obtained by 11 students in two sets, one held at
the beginning of a year and the other at the end of the year after intensive coaching. Do
thedataindicatethatthestudentshavebenefitedbycoachingat5%levelofsignificance? Test I :
19 23 16 24 17 18 20 18 21 1920
Test II : 17 24 20 24 20 22 20 20 18 22 19

4. Two random samples drawn from two normal populations with thefollowing
observations.
Sample I : 21 24 25 26 27
Sample II : 22 27 28 30 31 36
Write down the R programming code to test whether the two populations have the same
variance at 5 % level of significance.
CODES:

> # t-Test for singleMean


> print("H0 := x0=Mu")
[1] "H0 :=x0=Mu"
> print("H1 := x0!=Mu")
[1] "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
[1] 1.833113
> tCal=(x0-Mu)/(s/sqrt(n-1))
> tCal
[1] -0.5885024
> if(abs(tcal)<abs(tTab)){
+ print("H0 is accepted and H1 is rejected")
+ } else{
+ print("H0 is rejected and H1 is accepted")
+}
> if(abs(tCal)<abs(tTab)){
+ print("H0 is accepted and H1 is rejected")
+ } else{
+ print("H0 is rejected and H1 is accepted")
+}
[1] "H0 is accepted and H1 is rejected"
> t.test(x,mu=Mu)
One Sample t-test
data: x
t = -0.62034, df = 9, p-value = 0.5504
alternative hypothesis: true mean is not equal to 100
95 percent confidence interval:
86.98934 107.41066 sample estimates: Mean of x 97.2
> #t-Test for Difference ofMeans
> print("H0 := x1=x2")
[1] "H0 :=x1=x2"
> print("H1 := x1!=x2")
[1] "H1 :=x1!=x2"
> alpha=0.01
> n1=8
> n2=6
> x1=166.9
> x2=170.3
> s1=8.29
> s2=8.50
> Sigma=sqrt(((n1*s1^2)+(n2*s2^2))/(n1+n2-2))
> tTab=qt((1-alpha),(n1+n2-2))
> tTab
[1] 2.680998
> tCal=(x1-x2)/(Sigma*sqrt((1/n1)+(1/n2)))
> tCal
[1] -0.6954801
> if(abs(tCal)<abs(tTab)){
+ print("H0 is accepted and H1 is rejected")
+ } else{
+ print("H0 is rejected and H1 is accepted")
+}
[1] "H0 is accepted and H1 is rejected"
> #Paired t-Test andF-Test
> #paired t-Test Difference ofMeans
> print("H0 := x1=x2")
[1] "H0 :=x1=x2"
> print("H1 := x1!=x2")
[1] "H1 :=x1!=x2"
> alpha=0.05
> S1=c(19,23,16,24,17,18,20,18,21,19,20)
> S2=c(17,24,20,24,20,22,20,20,18,22,19)
> D=S1-S2
> d=mean(D)
> n=length(D)
> s=sqrt(var(D))
> tTab=qt((1-alpha),(n-1))
> tTab
[1] 1.812461
> tCal=d/(s/sqrt(n-1))
> tCal
[1] -1.313064
> if(abs(tCal)<abs(tTab)){
+ print("H0 is accepted and H1 is rejected")
+ } else{
+ print("H0 is rejected and H1 is accepted")
+}
[1] "H0 is accepted and H1 is rejected"
> #F-Test for Difference ofVariances
> print("H0 := s1=s2")
[1] "H0 :=s1=s2"
> print("H1 := s1!=s2")
[1] "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(S2)
> x1=mean(S1)
> x2=mean(S2)
> s1=sqrt(var(S1))
> s2=sqrt(var(S2))
> var1=(n1/(n1-1))*(s1^2)
> var2=(n2/(n2-1))*(s2^2)
> FTab=qf((1-alpha),(n1-1),(n2-1))
> FTab
[1] 5.192168
> if(var1>var2){
+ FCal=var1/var2
+ } else{
+ FCal=var2/var1
+}
> FCal
[1] 3.912453
> if(abs(FCal)<abs(FTab)){
+ print("H0 is accepted and H1 is rejected")
+ }else{
+ print("H0 is rejected and H1 is accepted")
+}
[1] "H0 is accepted and H1 is rejected"
> var.test(S1,S2)
F test to compare two variances
data: S1 and S2 F = 0.24537, num df = 4, denom df = 5, p-value =0.1981
alternative hypothesis: true ratio of variances is not equal to 1
95 percent confidence interval:
0.03321253 2.29776367
sample estimates:
ratio of variances
0.2453704

RESULT:
tTab tCal PrintResult’s

# t-Test forsingleMean : 1.833113 -0.5885024 "H0 is accepted and H1 isrejected"


#t-Test for DifferenceofMeans :2.680998 -0.6954801 "H0 is accepted and H1 is rejected"
#paired t-Test Difference ofMeans:1.812461 -1.313064 "H0 is accepted and H1 isrejected"
FTab FCal
#F-Test for Difference ofVariances:5.192168 3.912453 "H0 is accepted and H1 isrejected"
**THANK YOU**

You might also like