Str*_*tyk 0 plot r graph chi-squared probability-density
我试图在 R 中绘制卡方分布的密度函数图,其中 28 df 是 x 高于 7.5。
到目前为止,我从我能够收集到的信息中得到了这个:
x <- pchisq(7.5, 28, lower.tail=FALSE)
hist(x, prob=TRUE)
curve( dchisq(x, df=28), col='red', main = "Chi-Square Density Graph")
Run Code Online (Sandbox Code Playgroud)
但是绘图似乎不起作用._。
我想你想要:
curve( dchisq(x, df=28), col='red', main = "Chi-Square Density Graph",
from=0,to=60)
xvec <- seq(7.5,60,length=101)
pvec <- dchisq(xvec,df=28)
polygon(c(xvec,rev(xvec)),c(pvec,rep(0,length(pvec))),
col=adjustcolor("black",alpha=0.3))
Run Code Online (Sandbox Code Playgroud)
在这种情况下,该图有点傻,因为几乎曲线下的所有区域都带有阴影——概率x>7.5为
pchisq(7.5,df=28,lower.tail=FALSE)
## [1] 0.9999611
Run Code Online (Sandbox Code Playgroud)