Karissa Bianconi
Karissa Bianconi

Reputation: 11

Probability of a range of binomial event counts

I'm doing some problems on R and I am stuck on one that reads:

Given a binomial event with N=18 and p=.70, what is the probability of obtaining between 8 and 13 successful outcomes?

I know that in R you put in dbinom(x=,size=,prob=), but my actual question is what code could I use for this specific type of problem?

Upvotes: 1

Views: 1101

Answers (1)

josliber
josliber

Reputation: 44320

dbinom returns the probability that a particular number of events will occur, so you can just sum those probabilities for 8 through 13 events:

sum(dbinom(8:13, 18, .7))
# [1] 0.6612726

Alternately, pbinom returns the probability that that number or fewer events will occur, so you could use subtraction to compute the probability that between 8 and 13 events occurred:

pbinom(13, 18, .7) - pbinom(7, 18, .7)
# [1] 0.6612726

Upvotes: 6

Related Questions