Solved – Problem with pbinom in R (and binom.dist() in Excel)

I understand that the R-function

pbinom(0, 100, 0.5, lower.tail=FALSE)  

returns the probability of getting 0 or more heads in 100 trials. R gives the correct outcome, 1 for this problem. But if I use very small values for the probability in a single trial, as in

pbinom(0, 100, 0.0000000001, lower.tail=FALSE)  

I get an answer close to 0, actually: 1E-08, while I expected a result close to 1. Is this a bug? A similar thing occurs in Excel. But the propbability of ZERO or more successes in a binomial experiment should always be equal to 1. For the example above it is not important, because I know the answer already, but I am using the function pbinom() in a program.

Binomial distribution is

$$ Pr(X = k) = {nchoose k}p^k(1-p)^{n-k} $$

so with $k = 0$ this becomes

$$ {nchoose k}p^k(1-p)^{n-k} = {nchoose 0}p^0(1-p)^{n-0} = 1 times 1 times (1-p)^n = (1-p)^n$$

with lower.tail=FALSE you ask about $Pr(X>k)$, so basically for $Pr(X = 1)$, that is

$$ 1- (1-p)^n = 1 – (1 – 0.0000000001)^{100}$$

what gives you a correct answer. Check it if you want:

> 1-(1 - 0.0000000001)^100 [1] 1e-08 

Similar Posts:

Rate this post

Leave a Comment