Vous êtes sur la page 1sur 6

T Test and F test – Matlab 19-03-2019

Q:- An outbreak of salmonella-related illness was attributed to ice produced at a certain factory. Scientist
measured the level of Salmonella in 9 randomly sampled batches ice cream.The levels of MPN(g) levels
were:
a) 0.593 b)0.142 c)0.691 d)0.231 e)0.793 f)0.519 g)0.392 h)0.418
Given:-Ho=mu=0.3
H1=mu=0.3

Sol:-
x=c(0.593,0.142,0.329,0.691,0.231,0.793,0.519,.392,0.418)
xbar=mean(x)
alpha=0.05
mu=0.3
sd=sqrt(var(x))
n=length(x)
t=((xbar-mu)/(sd/sqrt(n)))
t
tv=qt(1-alpha,df=n-1)
tv
ifelse(ct>tv,"reject","accepct")

Output:-
> x=c(0.593,0.142,0.329,0.691,0.231,0.793,0.519,.392,0.418)
> xbar=mean(x)
> alpha=0.05
> mu=0.3
> sd=sqrt(var(x))
> n=length(x)
> t=((xbar-mu)/(sd/sqrt(n)))
> t
[1] 2.205059
> tv=qt(1-alpha,df=n-1)
> tv
[1] 1.859548
> ifelse(ct>tv,"reject","accepct")
[1] "reject"
Q2:- Suppose that 10 volunteers have taken an intelloigence test,hereare the results obtained.The average
score of the entire population is 75 in the same test. Is there any significant difference (LOS=95%) between
the sample and population means assuming that the variance of the population is not known

Scores : 65,78,88,55,48,95,66,57,79,81

Solution:- Ho=mu=75; H1=mu=/ 75

x=c(65,78,88,55,48,95,66,57,79,81)
xbar=mean(x)
alpha=0.05
mu=75
sd=sqrt(var(x))
n=length(x)
t=abs((xbar-mu)/(sd/sqrt(n-1)))
t
tv=qt(1-(alpha/2),df=n-1)
tv
ifelse(t>tv,"reject","accepct")

Output:-
> x=c(65,78,88,55,48,95,66,57,79,81)
> xbar=mean(x)
> alpha=0.05
> mu=75
> sd=sqrt(var(x))
> n=length(x)
> t=abs((xbar-mu)/(sd/sqrt(n-1)))
> t
[1] 0.7428466
> tv=qt(1-(alpha/2),df=n-1)
> tv
[1] 2.262157
> ifelse(t>tv,"reject","accepct")
[1] "accepct"
Q3:- Comparing two independent sample means,taken from two populations with unknown
variance. The following data shows the heights of indiviuals of two different
countries with unknown populations variances.Is there any significant difference
between the average heights of the two groups

A 175 168 168 190 156 181 182 175 174 179
B 185 169 173 173 188 186 175 174 179 180

Solution:- Ho:mu1=mu2; H1: mu1=mu2


x1=c(175,168,168,190,156,181,182,175,174,179)
x2=c(185,169,173,173,188,186,175,174,179,180)
alpha=0.05
n1=length(x1)
n2=length(x2)
x1bar=mean(x1)
x2bar=mean(x2)
sd1=sqrt(var(x1))
sd2=sqrt(var(x2))
t=abs(x1bar-x2bar)/(sqrt((sd1^2/n1)+(sd2^2/n2)))
tv=qt(1-(alpha/2),df=n-1)
tv
ifelse(t>tv,"reject","accepct")

Output:-
> x1=c(175,168,168,190,156,181,182,175,174,179)
> x2=c(185,169,173,173,188,186,175,174,179,180)
> alpha=0.05
> n1=length(x1)
> n2=length(x2)
> x1bar=mean(x1)
> x2bar=mean(x2)
> sd1=sqrt(var(x1))
> sd2=sqrt(var(x2))
> t=abs(x1bar-x2bar)/(sqrt((sd1^2/n1)+(sd2^2/n2)))
> tv=qt(1-(alpha/2),df=n-1)
> tv
[1] 2.262157
> ifelse(t>tv,"reject","accepct")
[1] "accepct"
Q4:- Suppose the recovery time for patients taking a new drug measured(in days). A
placebo group is also usedto avoid the placebo effect. The data are given as follows:-

With Drug 15 10 13 7 9 8 21 9 14 8
Placebo 15 14 12 8 14 7 16 10 15 2

Test whether the recovery time of the new drug group is greaterthan the placebo group

Solution:- H0=mu1=mu2; H1=mu1>mu2


x1=c(15,10,13,7,9,8,21,9,14,8)
x2=c(15,14,12,8,14,7,16,10,15,2)
alpha=0.05
n1=length(x1)
n2=length(x2)
x1bar=mean(x1)
x2bar=mean(x2)
sd1=sqrt(var(x1))
sd2=sqrt(var(x2))
t=abs(x1bar-x2bar)/(sqrt((sd1^2/n1)+(sd2^2/n2)))
tv=qt(1-(alpha/2),df=n-1)
tv
ifelse(t>tv,"reject","accepct")

Output:-
> x1=c(15,10,13,7,9,8,21,9,14,8)
> x2=c(15,14,12,8,14,7,16,10,15,2)
> alpha=0.05
> n1=length(x1)
> n2=length(x2)
> x1bar=mean(x1)
> x2bar=mean(x2)
> sd1=sqrt(var(x1))
> sd2=sqrt(var(x2))
> t=abs(x1bar-x2bar)/(sqrt((sd1^2/n1)+(sd2^2/n2)))
> tv=qt(1-(alpha/2),df=n-1)
> tv
[1] 2.262157
> ifelse(t>tv,"reject","accepct")
[1] "accepct"
F test

Q1:- Five measurements of the output of two units have given the following results (in kilograms per kg of
material per one hour of operation) Assume that both samples have been obtained from normalpopulations
test at1% LOS if two populations have the same variance

Unit A 14.1 10.1 14.7 13.7 14.0


Unit B 14.0 14.5 13.7 12.7 14.1

Solution:-
A=c(14.1,10.1,14.7,13.7,14.0)
B=c(14.0,14.5,13.7,12.7,14.1)
alpha=0.01
n1=length(A)
n2=length(B)
tv=qf(1-alpha,n1-1,n2-1)
F=var(A)/var(B)
ifelse(t>tv,"reject","accepct")

Output:-
> A=c(14.1,10.1,14.7,13.7,14.0)
> B=c(14.0,14.5,13.7,12.7,14.1)
> alpha=0.01
> n1=length(A)
> n2=length(B)
> tv=qf(1-alpha,n1-1,n2-1)
> F=var(A)/var(B)
> ifelse(t>tv,"reject","accepct")
[1] "accepct"
Q2:- In order to compare the effectiveness of two sources of nitrogen,namely ammonium chloride and urea
on grain yield of paddy,an experiment was conducted. The results on grain yield of paddy(kg/plot) under the
two treatments are given below

Ammonium Chlordie:- 13.4 10.9 11.2 11.8 14.0 15.3 14.2 12.6 17.0 16.2 16.5 15.7
Urea:- 12.0 11.7 10.7 11.2 14.8 14.4 13.9 13.7 16.9 16.0 15.6 16.0

Which sources nitrogen is better for paddy

Solution:-
A=c(13.4,10.9,11.2,11.8,14.0,15.3,14.2,12.6,17.0,16.2,16.5,15.7)
B=c(12.0,11.7,10.7,11.2,14.8,14.4,13.9,13.7,16.9,16.0,15.6,16.0)
alpha=0.01
n1=length(A)
n2=length(B)
tv=qf(1-alpha,n1-1,n2-1)
F=var(A)/var(B)
ifelse(t>tv,"reject","accepct")

Output:-
> A=c(13.4,10.9,11.2,11.8,14.0,15.3,14.2,12.6,17.0,16.2,16.5,15.7)
> B=c(12.0,11.7,10.7,11.2,14.8,14.4,13.9,13.7,16.9,16.0,15.6,16.0)
> alpha=0.01
> n1=length(A)
> n2=length(B)
> tv=qf(1-alpha,n1-1,n2-1)
> F=var(A)/var(B)
> ifelse(t>tv,"reject","accepct")
[1] "accepct"

Vous aimerez peut-être aussi