Anda di halaman 1dari 5

Tanishq Ram

17bee1182

STATISTICS FOR ENGINEERS


ASSIGNMENT PROBLEMS
LAB 6

PROBLEM 1:

xbar=2.1
mu0=2
sigma=0.25
n=35
t_s=(xbar-mu0)/(sigma/sqrt(n))
t_s
z = abs(t_s)
alpha = 0.05
zalpha = qnorm(1-alpha)
zalpha
ifelse(z>zalpha, "reject", "accept")
val=pnorm(t_s)
pval=1-val
pval
OUTPUT:
> t_s
[1] 2.366432
> zalpha
[1] 1.644854
> ifelse(z>zalpha, "reject", "accept")
[1] "reject"
> pval
[1] 0.008980239

The test statistic is greater than zalpha=1.644854. Hence, at 0.05


significance level, we reject the claim that there is at most 2 grams of
saturated fat in cookies. The upper tail p-value of the test statistic is less
than the significant level 0.05, we reject the null hypothesis that mu<=2.

PROBLEM 2:
p=12/30
p0=12
q0=1-p0
n=30
z=(p-p0)/sqrt(p*q0/n)
z
alpha=0.05
zhalfalpha = qnorm(1-(alpha/2))
ifelse(z>zhalfalpha, "reject", "accept")
c(-zhalfalpha, zhalfalpha)
pval=2*pnorm(z, lower.tail = FALSE)
pval

OUTPUT:
>z
[1] 1.095445

> ifelse(z>zhalfalpha, "reject", "accept")


[1] "accept"

The test statistic (z=1.095445) is between the critical values of -1.96000


and 1.96000. Hence, at 0.05 significance level, we accept the null
hypothesis that the coin toss is fair. The p-value of the test statistic is
greater than the significant level 0.05, we do not reject (i.e. accept) the
null hypothesis that the coin toss is fair.

LAB 7

PROBLEM 1:

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

OUTPUT:
> cr
[1] 0.9394539
> tv
[1] 2.100922
> ifelse(ct>tv,"reject","accept")
[1] "accept"

PROBLEM 2:

x=c(15,10,13,7,9,8,21,9,14,8)
y=c(15,14,12,8,14,7,16,10,15,2)
xbar = mean(x)
ybar = mean(y)
alpha = 0.05
sd1=sqrt(var(x))
sd2=sqrt(var(y))
n1=length(x)
n2=length(y)
ct=abs((xbar-ybar)/(sqrt(((n1*sd1^2 + n2*sd2^2)/(n1+n2-2))* (1/n1 +
1/n2))))
ct
tv=qt(1-(alpha),n1+n2-2)
tv
ifelse(ct>tv,"reject","accept")

OUTPUT:
> ct
[1] 0.04793613
> tv
[1] 1.734064
> ifelse(ct>tv,"reject","accept")
[1] "accept"
LAB 8

PROBLEM 1:
x=c(14.1,10.1,14.7,13.7,14.0)
y=c(14.0,14.5,13.7,12.7,14.1)
alpha = 0.05
n1=length(x)
n2=length(y)
tf=qf(1-alpha,n1-1,n2-1)
tf
cf=var(x)/var(y)
cf
ifelse(cf>tf,"reject","accept")

OUTPUT:

> tf
[1] 6.388233
> cf
[1] 7.330435
> ifelse(cf>tf,"reject","accept")
[1] "reject"

LAB 9
PROBLEM 1 :

data<-matrix(c(35,42,61,48,51,68),ncol=3,byrow=T)
data
chisq.test(data)

OUTPUT:
> data
[,1] [,2] [,3]
[1,] 35 42 61
[2,] 48 51 68
> chisq.test(data)
Pearson's Chi-squared test
data: data
X-squared = 0.53441, df = 2, p-value = 0.7655

LAB 10
PROBLEM 1:
group2<-c(52,33,8,47,43,32)
group1<-c(22,42,44,52,45,37)
group3<-c(16,25,19,18,34,39)
group<-data.frame(cbind(group1,group2,group3))
summary(group)
stgr<-stack(group)
crd<-aov(values~ind,data=stgr)
summary(crd)
boxplot(group, ylab= "MEAN SALES", main="SALES FIGURES")

OUTPUT:
> summary(group)
group1 group2 group3
Min. :22.00 Min. : 8.00 Min. :16.00
1st Qu.:38.25 1st Qu.:32.25 1st Qu.:18.25
Median :43.00 Median :38.00 Median :22.00
Mean :40.33 Mean :35.83 Mean :25.17
3rd Qu.:44.75 3rd Qu.:46.00 3rd Qu.:31.75
Max. :52.00 Max. :52.00 Max. :39.00
> summary(crd)
Df Sum Sq Mean Sq F value Pr(>F)
ind 2 728.1 364.1 2.483 0.117
Residuals 15 2199.0 146.6

Anda mungkin juga menyukai