2015-10-31 45 views
1

的曲線圖我已經使用找到的概率..繪製使用dnorm和多邊形功能中的R

pnorm(176, 135, 10, lower.tail=TRUE) - pnorm(146, 135, 10, lower.tail=TRUE) 

這導致0.1356,約14%。

我必須使用dnorm和多邊形函數來創建一個圖表,它顯示了正常分佈中陰影區域(基於上述百分比)。

任何人都知道如何做到這一點?

回答

1

事情是這樣的:

library(ggplot2) 

x=seq(80,190,1) 
dat = data.frame(x, dens=dnorm(x,135,10)) 

ggplot(dat, aes(x,dens)) + 
    geom_line() + 
    geom_area(data=dat[dat$x >= 146 & dat$x <= 176,], 
      fill="red") 

enter image description here