【问题标题】:2 Binomial Distributions Overlap in R2 二项分布在 R 中重叠
【发布时间】:2016-10-29 04:55:04
【问题描述】:

我将如何用不同的方法制作两个二项式 pdf 的图表,并用阴影或其他任何东西填充重叠?

【问题讨论】:

标签: r visualization binomial-theorem


【解决方案1】:

试试这个:

df <- rbind(data.frame(binom=rbinom(1000, 20, 0.2), binomial.p='0.2') , data.frame(binom=rbinom(1000, 20, 0.5),binomial.p='0.5'))
library(ggplot2)
ggplot(df, aes(binom, fill=binomial.p)) + 
geom_histogram(position = 'dodge', binwidth = 1) + 
xlab('Number of success (n=20)')

ggplot(df, aes(binom, fill=binomial.p)) + 
geom_density(alpha=0.2) + 
xlab('Number of success (n=20)')

【讨论】:

    猜你喜欢
    • 2018-10-21
    • 2013-08-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-11-11
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多