This question already has an answer here:

Specifically, let's say I take a random sample of 20 products from a manufacturing batch of 1000 and they all tested good, what assumptions and conclusions can I make about the whole batch? Is it possible to say "There is an x% chance that the entire batch is good"? How could I calculate x in this case? Note that this is assuming I have no prior knowledge of what the defect rate should be.


marked as duplicate by kjetil b halvorsen, mdewey, Silverfish, Michael Chernick, Juho Kokkala Aug 9 '17 at 7:18

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


20 of 1000 are good. For rest 980, number of good ones can be from 0 to 980. Calculate the probabilities that a random sample of 20 products from a manufacturing batch of 1000 and they all tested good, when # of good ones are 20, 21, ..., 1000 among 1000. (totally 981 probabilities). Add them together as denominator, and last one (1000 goods among 1000) as numerator. This ratio is your x.

Let $Y$ be the number of good ones among 1000 products. Because no prior information, we assume $\Pr(Y=k) = 1/1001$ because $Y$ can be 0, 1, ..., 1000. It is uniform distribution and is used as no informative prior very often.

Let $B$ be the event that all of 20 products are good in the random sample of 20 from 1000 products.

So the asked question is


So $\Pr(Y=1000|B) = \frac{Pr(B|Y=1000)\Pr(Y=1000)}{\sum_{y=0}^{1000}\Pr(B|Y=y)\Pr(Y=y)}$



$=1/47.666667 = 0.02097902$ appr. 2.1%

Under the assumption of simple random sample, the # of good ones among 20 sampled units follows hyper-geometric distribution. So

$\Pr(B|Y=y)={\frac {{\binom {y}{20}}{\binom {980}{0}}}{\binom {1000}{20}}} = \frac {{\binom {y}{20}}}{\binom {1000}{20}}$. Need to know that $\binom {y}{20}= 0 $ for $y<20$

In fact, calculation can be performed by any software with probability density function of hyper-geometric distribution.

  • $\begingroup$ This recipe does not seem to correspond to any classical confidence limit or Bayesian estimate. Do you have a reference? $\endgroup$ – whuber Apr 27 '17 at 13:31
  • $\begingroup$ Bayes' theorem. $\endgroup$ – user158565 Apr 27 '17 at 14:04
  • 1
    $\begingroup$ I owe you an apology for having confused the question: you have been addressing (correctly) the chance that the entire population is good, whereas I shifted the discussion to estimating the mean of the posterior distribution. The results we are getting are consistent. For instance, returning to the Beta$(1,22)$ approximation, I would estimate the chance of less than $1/1000$ of the population being bad is $0.02177$, quite consistent with your answer. Along with the apology goes an upvote. $\endgroup$ – whuber Apr 27 '17 at 21:57
  • 1
    $\begingroup$ Nice! But you should probably explain why $\frac{Pr(B|Y=1000)}{\sum_{y=0}^{1000}\Pr(B|Y=y)}=1/47.666667$. The numerator is easy (of course the probability of drawing 20 good products from a population where all products are good is 1), but computing the denominator $\sum_{y=0}^{1000}\Pr(B|Y=y)=\sum_{y=20}^{1000}\Pr(B|Y=y)$ is not as simple and requires a model for sampling w/o replacement. You should at least sketch how it's done. $\endgroup$ – DeltaIV Apr 27 '17 at 22:46
  • 1
    $\begingroup$ Added the computation of $\Pr(B|Y=y)$ into Answer. $\endgroup$ – user158565 Apr 29 '17 at 17:10

You can construct a confidence interval for the proportion p that are not defective. The interval will be one-sided [p$_c$, 1] say 95% this gives you an idea based on the width of the interval ( [1-p$_c$,1] ) how confident you are that the proportion is close to 100%. This would be based on the hypergeometric distribution.

Based on Bill Huber's comment about the Bayesian approach. This shows that a lot can be said without prior knowledge. This computation is based strictly on frequentist methods.

  • 1
    $\begingroup$ "Based on the hypergeometric distribution" is correct but may be misleading, because the calculation is dead simple and does not require any knowledge of the hypergeometric distribution. See en.wikipedia.org/wiki/Rule_of_three_(statistics). $\endgroup$ – whuber Apr 27 '17 at 13:32
  • 2
    $\begingroup$ @whuber I think the important thing to say was that a confidence interval might be the right way to think of the problem. I was the first to answer this question. I mentioned the hypergeometric distribution because that is the distribution that applies in this case and the OP might not be aware of this. $\endgroup$ – Michael Chernick Apr 27 '17 at 13:37
  • 1
    $\begingroup$ Those are excellent points. I think your answer would be stronger if you were to emphasize them, especially because the question has been phrased in a Bayesian way. $\endgroup$ – whuber Apr 27 '17 at 13:45

Not the answer you're looking for? Browse other questions tagged or ask your own question.