如果给出 属性 的机会,则 3 个中有 1 个的机会有 属性? (如何在 R 中计算?)
Chance of 1 of 3 has a property if chance for the property is given? (How to calc in R?)
我在一篇论文中找到了这句话:
In individuals of Northern European ancestry, as many as 8 percent of men and 0.5 percent of women experience the common form of red-green color blindness. If a submitted manuscript happens to go to three male reviewers of Northern European descent, the chance that at least one will be color blind is 22 percent.
Wong, B.: 观点:色盲, Nat Methods, 8(6), 441–441, doi:10.1038/nmeth.1618, 2011.
我如何在 R 中计算这个?提前致谢。
这是一个非常容易解决的问题,无需深入了解二项分布。
prob_male_colorblind=0.08
prob_of_male_not_colorblind=1-prob_male_colorblind
prob_of_three_males_not_colorblind=prob_of_male_not_colorblind^3
prob_of_at_least_one_male_not_colorblind=1-prob_of_three_males_not_colorblind
另一种方法是根据经验来做,而不是乔的回答的分析方法:
n = 100000 #Arbitrary large number
at.least.1 = numeric() #Empty vector to store "1" when at least one was colorblind, "0" if not
for(j in 1:n){
at.least.1[j] = sum(sample(0:1, size=3, prob=c(0.92,0.08), replace=TRUE))>=1}
sum(at.least.1)/n
这道题很容易解析,但有时这样会更好。
“至少一道”概率题由1 - prob(none)解出。因此,如果 0.08 人是 color-blind,那么 0.92 人不是。所以这 3 个人中 none 是色盲的概率是:
p3 <- 0.92^3
0.778688
并且至少有 1 人是色盲的概率:
at_least_1 <- 1- p3
0.221312
我在一篇论文中找到了这句话:
In individuals of Northern European ancestry, as many as 8 percent of men and 0.5 percent of women experience the common form of red-green color blindness. If a submitted manuscript happens to go to three male reviewers of Northern European descent, the chance that at least one will be color blind is 22 percent.
Wong, B.: 观点:色盲, Nat Methods, 8(6), 441–441, doi:10.1038/nmeth.1618, 2011.
我如何在 R 中计算这个?提前致谢。
这是一个非常容易解决的问题,无需深入了解二项分布。
prob_male_colorblind=0.08
prob_of_male_not_colorblind=1-prob_male_colorblind
prob_of_three_males_not_colorblind=prob_of_male_not_colorblind^3
prob_of_at_least_one_male_not_colorblind=1-prob_of_three_males_not_colorblind
另一种方法是根据经验来做,而不是乔的回答的分析方法:
n = 100000 #Arbitrary large number
at.least.1 = numeric() #Empty vector to store "1" when at least one was colorblind, "0" if not
for(j in 1:n){
at.least.1[j] = sum(sample(0:1, size=3, prob=c(0.92,0.08), replace=TRUE))>=1}
sum(at.least.1)/n
这道题很容易解析,但有时这样会更好。
“至少一道”概率题由1 - prob(none)解出。因此,如果 0.08 人是 color-blind,那么 0.92 人不是。所以这 3 个人中 none 是色盲的概率是:
p3 <- 0.92^3
0.778688
并且至少有 1 人是色盲的概率:
at_least_1 <- 1- p3
0.221312