Search code examples
rstatisticsbinomial-coefficients

Chance of 1 of 3 has a property if chance for the property is given? (How to calc in R?)


I found this quote in a paper:

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.: Points of view: Color blindness, Nat Methods, 8(6), 441–441, doi:10.1038/nmeth.1618, 2011.

How could I calculate this in R? Thanks in advance.


Solution

  • Another way is to do it empirically, instead of the analytical way of Joe's answer:

    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
    

    For this problem it's easy to do it analytically, but sometimes this will be better.