两条H0、H1下的概率分布曲线,以及添加第一类错误、第二类错误的标签
x1 = seq(-5, 5, length.out = 500)
x2 = seq(-1, 9, length.out = 500)
y1 = dnorm(x1, 0, 1.5)
y2 = dnorm(x2, 4, 1.5)
plot(x1, y1, xlim = c(-6, 10), ylim = c(0.01, 0.26),
frame.plot = T, axes = F, ann = F, type = "l")#去掉标签、刻度
lines(x2, y2)
segments(x0 = 2.5, y0 = -0.012, x1 = 2.5, y1 = dnorm(2.5, 4, 1.5))#添加竖线
#阴影1
region.x2 = x2[-1 <= x2 & x2 <= 2.5]
region.y2 = y2[-1 <= x2 & x2 <= 2.5]
region.x2 = c(region.x2[1], region.x2, tail(region.x2, 1))
region.y2 = c(0, region.y2, 0)
polygon(region.x2, region.y2, density = 10)
#阴影2
region.x1 = x1[2.5 <= x1 & x1 <= 5]
region.y1 = y1[2.5 <= x1 & x1 <= 5]
region.x1 = c(region.x1[1], region.x1, tail(region.x1, 1))
region.y1 = c(0, region.y1, 0)
polygon(region.x1, region.y1, density &#