我想在此图中指出此链接中的多个分位数。
x <- rnorm(1000,0,1)
me <- mean(x)
s <- sd(x)
y <- 1/sqrt(2*pi)/s*exp(-(x-me)^2/2/s/s)
sx <- sort(x)
n <- seq(1, length(sx),1)
Px <- (3*n-1)/(3*length(sx)+1)
plot(sx,Px)
lines(sx, pnorm(sx, mean=me, sd = s), lwd=3, col="red")
您会推荐哪个功能?到目前为止,我已经计算了这么多的分位数。
qq<-quantile(x,c(0.5,0.95))
你可以试试:
# data
set.seed(1221)
x <- rnorm(1000,0,1)
# [your code to plot the graph]
# Quantiles
P <- c(0.05, .25, 0.5, 0.75, 0.95) # The quantiles you want to calculate
qq <- quantile(x, P)
df <- cbind(P, qq)
# the segments
apply(df, 1, function(x) segments(x0 = x[2], x1 = x[2], y0 = -10, y1 = x[1], lty = 2, col = 2))
apply(df, 1, function(x, y) segments(x0 = y-10, x1 = x[2], y0 = x[1], y1 = x[1], lty = 2, col = 2), min(x))
编辑
# add the text, not that elegant, but it works:
sapply(1:length(names(qq)), function(x) text(df[x,2], -0.08, bquote(Q[ ~ .(names(qq)[x])]), xpd = TRUE))
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句