Professional Documents
Culture Documents
21bce0427 VL2022230503921 Ast05
21bce0427 VL2022230503921 Ast05
NAME: Chethan N V
REG.NO: 21BCE0427
Slot: L5+L6
data: nails
t = -0.25916, df = 9, p-value = 0.8013
alternative hypothesis: true mean is not equal to 7
95 percent confidence interval:
6.805424 7.154576
sample estimates:
mean of x
6.98
> #H0: The mean length of nails produced by the machine is 7 cms.
> #H1: The mean length of nails produced by the machine is not equal to 7
cms.
>
> #The p-value is 0.8013 , which is greater than the significance level of
0.05, indicating that we fail to reject the null hypothesis.
> #Therefore, we can conclude that there is not enough evidence to suggest
that the mean length of nails produced by the machine is different from 7
cms, and we cannot say anything about the reliability of the machine based
on this sample.
>
Screenshot:
Problem 2:
Aim: t-test
Code:
> #Name: Chethan N V
> #Reg No: 21BCE0427
>
> #Question 2
>
> before = c(45, 73, 46, 124, 33, 57, 83, 34, 26, 17)
> after = c(36, 60, 44, 119, 35, 51, 77, 29, 24, 11)
>
> #Null hypothesis (H0): The safety program is not effective
in reducing accidents.
> #Alternative hypothesis (Ha): The safety program is
effective in reducing accidents.
>
> # perform paired t-test
> t.test(before, after, paired = TRUE, alternative = "less",
conf.level = 0.95)
Paired t-test
Code:
> #Name: Chethan N V
> #Reg no: 21BCE0427
>
> #Question 3
>
>
> obs_freq=c(17, 52, 54, 31, 6)
> n=sum(obs_freq)
> exp_freq=dbinom(0:4, 4, 0.5)*n
> exp_freq
[1] 10 40 60 40 10
>
> exp_freq1 =dbinom(0:4, 4, 0.5)*sum(obs_freq)
> # perform chi-squared test
> chisq.test(obs_freq,p=dbinom(0:4, 4, 0.5), rescale.p = TRUE)
data: obs_freq
X-squared = 12.725, df = 4, p-value = 0.0127
Code:
> #Name: Chethan N V
> #Reg No; 21BCE0427
> #Question 4
>
> #sample 1
> x = c(16, 26, 27, 23, 24, 22)
>
> #sample 2
> y = c(33, 42, 35, 32, 28, 31)
>
> #perform F-test
>
> var.test(x,y)
data: x and y
F = 0.6696, num df = 5, denom df = 5, p-value = 0.6706
alternative hypothesis: true ratio of variances is not equal to 1
95 percent confidence interval:
0.09369826 4.78524246
sample estimates:
ratio of variances
0.6696035
> #Null hypothesis (H0): The variances of the two populations are
equal.
> #Alternative hypothesis (Ha): The variances of the two
populations are not equal.
>
>
> #TThe p-value is -.6706 which is greater than 0.05, this
indicates that we cannot reject null hypothesis that the variances
of the two populations are equal.
>
> #Therefore we can conclude that the estimates of variances do
not differ significantly.
>
>
Screenshot:
Problem 5:
Code:
> #Name: Chethan N V
> #Regno: 21BCE0427
>
> #Question 5
>
> Salesman = c(rep("A", 3), rep("B", 3), rep("C", 3), rep("D", 3))
> Season = c(rep(c("Summer", "Winter", "Monsoon"), 4))
> Sales = c(36, 28, 26, 36, 29, 28, 21, 31, 29, 35, 32, 29)
> Total = c(128, 120, 112, 90, 93, 81, 96, 360)
> )
Error: unexpected ')' in ")"
>
> sales_data <- data.frame(Salesman,Season,Sales,Total)
Error in data.frame(Salesman, Season, Sales, Total) :
arguments imply differing number of rows: 12, 8
> Total = c(128, 120, 112, 90, 93, 81, 96, 360,0,0,0,0)
> sales_data <- data.frame(Salesman,Season,Sales,Total)
>
> # perform two-way ANOVA
> result <- aov(Sales ~ Salesman + Season, data = sales_data)
> summary(result)
Df Sum Sq Mean Sq F value Pr(>F)
Salesman 3 42 14.00 0.618 0.629
Season 2 32 16.00 0.706 0.531
Residuals 6 136 22.67
>
>
> #The null hypothesis for the two-way ANOVA test is that there is no
significant difference among the means of the sales of the four
salesmen in three seasons.
> #The alternative hypothesis is that there is a significant
difference among the means of the sales of the four salesmen in three
seasons.
>
>
> #The p-value for the Salesman factor is 0.629, which is greater than
the significance level of 0.05, indicating that there is no
significant difference among the means of the four salesmen.
> #The p-value for the Season factor is 0.0531, which is greater than
the significance level of 0.05, indicating that there is not enough
evidence to reject the null hypothesis that there is no significant
difference among the means of the three seasons.
>
>
> #Therefore, we can conclude that there is a significant difference
among the means of the four salesmen with regard to the sales, but no
significant difference among the means of the three seasons.
Screenshot: