How many simultaneous independent events needed to have a certain probability of getting at least X specific outcomes

43 Views Asked by At

Each cup of coffee I purchase has random 60% probability of having my name spelled correctly on the cup. If I want to have an 80% chance of having at least $x$ correctly spelled coffee cups for my collection, how many coffees do I need to purchase?

I can afford an infinite number of coffees from my local coffee shop, but I can only make one order (all the cups will arrive at the same time).

I've seen this question which feels related but I'm not sure how to extend that to desiring a certain number of successes.

1

There are 1 best solutions below

0
On

You can basically use the same technique as in the linked post. If you purchase n cups of coffee, the number of cups with your name correctly spelled on it has binomial distribution $X\sim \mathscr B(n, .6)$. We are interested in the probability that the number of cups purchased with your name correctly spelled on it is at least x, that is, $P(X\ge x)$. We know for a binomial distribution this is $\sum_{k=x}^{n}P(X=k)$. And we want this quantity to be greater than $80\%$, that is, getting at least x cups with your name correctly spelled with a probability of at least $80\%$. You simply find the smallest n such that $\sum_{k=x}^n{n\choose k}.6^k.4^{n-k}\ge .8$. This can be done using the pbinom command. If, for example, you wanted to find the number of cups you should purchase to have at least 80% chance of getting 5 cups with your name spelled right, you would find

> print(pbinom(4, 9, .6, lower.tail=FALSE))
[1] 0.7334323

but

> print(pbinom(4, 10, .6, lower.tail=FALSE))
[1] 0.8337614

therefore you need to buy 10 cups to have the probability of getting at least 5 cups with your name spelled right to be at least 80%. More generally, you can use the following code to find the number of purchases needed

cupsrightname=5
for (k in 1:100) {
  w=pbinom(cupsrightname-1, k, .6, lower.tail=FALSE)
  if (w>=.8) {
    print(k)
    break
  }
}

-out

[1] 10