Confidence interval for probability equal to 0

I meet this real life problem. The simplified version is this:

Assuming I have 10000 apples, either good or bad. What is the sample size if I want to be 95% sure that all the apples are good?

-
It seems like you're not asking the question that you really want answered. If you want to be 95% sure that the probability that you have a bad apple in the bunch is zero, then your sample size should be 9,500. Another question you might be able to answer might be how many apples do you need in order to be sure that the proportion of good apples is above 95% with 95% confidence if all of the apples you sample are good. For that the answer would be 59, because $0.95^{59} < 0.05$. – Sam Dickson May 9 '14 at 17:47

One (standard) interpretation of this question is that you seek a randomized sampling procedure that has at least a 95% chance of including at least one bad apple, should there happen to be a bad apple in the population. Equivalently, the chance of not including it cannot exceed 5%.

In the worst case, there is only one bad apple in $n=10000$ apples. The chance this will not be included in a random sample of size $k$ (without replacement) is the number of samples of the $n-1$ good apples divided by the total number of samples of all $n$ apples. This implies

$$0.05 \ge \frac{\binom{n-1}{k}}{\binom{n}{k}} = 1 - \frac{k}{n}.$$

The solution is

$$k \ge (1 - 0.05)n,$$

requiring a minimum sample of $9500$ in this case.

-
I'm entirely convinced about this answer, but I don't have a better answer yet. Some of my friends think this should be related to en.wikipedia.org/wiki/Bayesian_statistics – Daiwei May 12 '14 at 21:55
Yes, a Bayesian analysis would be apt here: but it is not necessary. In a comment, @Sam Dickson reframes your question in a standard non-Bayesian way and provides an (approximate) answer. (The answer is approximate in that it does not account for the finite population--which is fine for the numbers he mentions, but could be important when other percentages are involved.) In the Bayesian case you must supply a prior distribution for the numbers of bad apples; in the non-Bayesian case you must decide what proportion of bad apples it is important to detect. – whuber May 12 '14 at 22:08