Statistics Question

I have a work related question that I think is a relatively easy stats question, but can’t for the life of me remember what how to do it.

Say you have a factory that produces widgets with a known defective rate of x%. How many do you need to inspect before you are likely to find a defective one? How about before you are guaranteed to find one?

Is this a confidence interval question? It seems like it is, but I can’t quite get those numbers to work.
Muchos gracias.

The latter is an easy one. You are never guaranteed to find one. There is nothing inconsistent about a factory with an x% failure rate to produce any arbitrarily long string of non-failing widgets.

For the former, assuming independence between successive widgets, the probability of a sequence of n widgets being defect free is (1-x)^n, so I guess when that quantity gets below 50%, that’s when you’re more likely than not to find one.

If you examine N widgets, each widget has a probability p of being defective, and the probability that a given widget is defective is independent of any other widget being defective, then the probability that all of the widgets are good is (1 - p)[sup]N[/sup]. In particular, this never quite goes to zero, so you’re never guaranteed to find a defective widget — you could just have a run of good (bad?) luck.

If you want there to be a 50-50 chance of finding at least on defective widget in a sample of size N, then you want it to be the case that

0.5 = (1 - p)[sup]N[/sup]

which, after some manipulation, is equivalent to

N = log(0.5)/log(1-p).

For example, if p = 10%, then N = 7 (well, 6.5); if p = 1%, N = 69; and if p = 0.1%, N = 693.

This is a negative binomial problem.