mug mug - 1 month ago 16
R Question

How do I find binomial distribution using R?

Harry is a basketball player.His probability of making a free throw is 0.70.
-> what is the probability that Harry makes his third free throw on his fifth shot?

things I have tried so far; given p=0.70 n = 5

sum(dbinom(3:5,n,p))


And I got 0.83, but I know that answer is 0.18.

pbinom(5,n,p)-pbinom(2,n,p)


Can someone please help me.

Answer

If he gets 3rd free throw on 5th shot, then

  • the previous 4 shots have 2 free throws;
  • the 5th shot is a free throw

Note, these two events are independent, while the probability of the first is dbinom(2, 4, 0.7), and the probability of the last is 0.7. So

dbinom(2, 4, 0.7) * 0.7
# [1] 0.18522

Note, there is really a trap here. It is so easy to assume the answer as

dbinom(3, 5, 0.7)
# [1] 0.3087

But that only means we have 3 free throws out of 5 shots, which does not guarantees the 5th shot is a free throw.