酷代码 AI
菜单
全部AI  /  热门  /  AI写代码神器
服务商

r语言代码 2. 完成练习: 以下是 15 名学生通过某课程强化集训前后的测试成绩: 学生: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 集训前 82 59 77 50 64 76 55 64 75 75 62 79 81 73 60 集训后 97 64 75 67 89 70 66 91 67 75 86 86 85 96 80 根据这一样本, i)写出原假设与备择假设; ii)计算检验统计量的样本值; iii)检验该课程的这种强化集训能否提升学生成绩 1)大于 5 分;2)小于 10 分。其中显著性 水平为 0.05

```R # 原假设与备择假设 # 原假设:强化集训前后学生成绩没有显著提升(即平均成绩没有变化) # 备择假设:强化集训前后学生成绩有显著提升(即平均成绩有变化) # 计算检验统计量的样本值 before <- c(82, 59, 77, 50, 64, 76, 55, 64, 75, 75, 62, 79, 81, 73, 60) after <- c(97, 64, 75, 67, 89, 70, 66, 91, 67, 75, 86, 86, 85, 96, 80) # 使用配对样本 t 检验 t_stat <- t.test(before, after, paired=TRUE)$statistic print(t_stat) # 检验该课程的这种强化集训能否提升学生成绩 # 1) 大于 5 分 p_value_5 <- 1 - pt(t_stat, df = 14) if (p_value_5 < 0.05) { print("Reject the null hypothesis: the training can improve student scores by more than 5 points.") } else { print("Fail to reject the null hypothesis.") } # 2) 小于 10 分 p_value_10 <- pt(t_stat, df = 14) if (p_value_10 < 0.05) { print("Reject the null hypothesis: the training can improve student scores by less than 10 points.") } else { print("Fail to reject the null hypothesis.") } ``` [2024-11-26 22:00:01 | AI写代码神器 | 630点数解答]

相关提问