#Q.1
Energy_In_take<-c(5260,5470,5640,6180,6390,6515,6805,7515,8230,8770)
mean(Energy_In_take)
## [1] 6677.5
var(Energy_In_take)
## [1] 1378535
sd(Energy_In_take)
## [1] 1174.11
boxplot(Energy_In_take)

shapiro.test(Energy_In_take)
##
## Shapiro-Wilk normality test
##
## data: Energy_In_take
## W = 0.93468, p-value = 0.4955
alpha<- 0.05
t.test(Energy_In_take)
##
## One Sample t-test
##
## data: Energy_In_take
## t = 17.985, df = 9, p-value = 2.312e-08
## alternative hypothesis: true mean is not equal to 0
## 95 percent confidence interval:
## 5837.592 7517.408
## sample estimates:
## mean of x
## 6677.5
#Q.2
# Given data
values <- matrix(c(120, 110, 90, 95, 40, 45), nrow = 2)
colnames(values) <- c("Republican", "Democratic", "Independent")
rownames(values) <- c("Male", "Female")
# Perform Chi-Square Test of Independence
chi_square_result <- chisq.test(values)
# Degrees of freedom
df <- (nrow(values) - 1) * (ncol(values) - 1)
# Significance level
alpha <- 0.05
# Calculate critical value
critical_value <- qchisq(1 - alpha, df = df)
# Compare with the Chi-Square test
if (chi_square_result$statistic > critical_value) {
cat("Reject the null hypothesis. There is evidence of an association between gender and political party preference.\n")
} else {
cat("Fail to reject the null hypothesis. There may not be a significant association between gender and political party preference.\n")
}
## Fail to reject the null hypothesis. There may not be a significant association between gender and political party preference.
# Print the result
print(chi_square_result)
##
## Pearson's Chi-squared test
##
## data: values
## X-squared = 0.86404, df = 2, p-value = 0.6492
#Q.3
#data <- data.frame(
# student = rep(c("A", "B", "C"), each = c(6, 5, 6)),
# value = c(52, 46, 62, 48, 57, 54, 63, 49, 64, 53, 68, 63, 65, 58, 70, 71, 73)
#)
data_list <- list(
studenta = c(52, 46, 62, 48, 57, 54),
studentb = c(63, 49, 64, 53, 68),
studentc = c(63, 65, 58, 70, 71, 73)
)
#model <- aov(value ~ student, data = data)
#summary(model)
kw_result <- kruskal.test(data_list)
print(kw_result)
##
## Kruskal-Wallis rank sum test
##
## data: data_list
## Kruskal-Wallis chi-squared = 8.3472, df = 2, p-value = 0.0154