【问题标题】:Drawing a graph using dnorm and polygon function in R在 R 中使用 dnorm 和多边形函数绘制图形
【发布时间】:2016-01-31 13:08:29
【问题描述】:

我用..找到了概率。

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

结果为 0.1356,约为 14%。

我必须使用 dnorm 和多边形函数来创建一个图形,其中它显示了正态分布中的阴影区域(基于上述百分比)。

有人知道怎么做吗?

【问题讨论】:

    标签: r graphics visualization probability normal-distribution


    【解决方案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")
    

    【讨论】:

      猜你喜欢
      • 2015-01-01
      • 2018-08-31
      • 2012-03-19
      • 1970-01-01
      • 1970-01-01
      • 2021-02-08
      • 2017-06-25
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多