# Find sample size to be x% confident that our population has no defects

I am trying to find a way to affirm with certain confidence that a batch of products have no defects at all.

This question is very similar to this one but I do not know, nor can assume, any percentage of defects, because there can not be any.

How can I find a sample size to be, let's say, 90% confident, that my 1000 products batch has no deffects at all?

• Do you have some previous historical data which you can use to estimate how many defects you had in the past? The answer will depend a lot on the expected number of defects. If you have a lot of defects then a smaller sample will be enough since you will observe defects faster. If you have very few defects then you will need a larger sample to have the same confidence. Jan 11, 2023 at 11:48
• No, I do not have historical data. Our intent is to check for the first time whether this initial batch has defects without a previous history. An approach we tried is the six sigma methodology but there is no apparent way given that we do not have an expected amount of defects. Jan 11, 2023 at 12:31
• Then you are proverbially screwed. How can you tell with any confidence if there defects or not if you do not know how frequent they are? Suppose I told you there are 990 defects out of 1000, how big do you think your sample needs to be? What if there is 1 defect out of 1000? This frequency entirely determines the solution to your problem. Jan 11, 2023 at 12:37

Let K be the number of defective products in the 1000 products batch and X the number of defective products in a sample of size n. Assume the observed value of X is 0. X follows a hypergeometric distribution, therefore:

$$P(X=0)=\cfrac{{K\choose0}{1000-K\choose n}}{1000\choose n}=\cfrac{\cfrac{(1000-K)!}{(1000-K-n)!n!}}{\cfrac{1000!}{(1000-n)!n!}}$$

You have to test the null hypothesis $$H_{0}: K>0$$ against the alternative $$H_{1}: K=0$$.

As the null hypothesis is composite, the p-value is the maximum probability under the null hypothesis of X taking a value at least as extreme as the observed value, that is, the maximum probability under the null hypotheiss of X=0. The maximum probability is reached for K=1 (because the probability of getting no defective products in your sample is greater when there are fewer defective products in the batch). Therefore, when the observed value of X is 0, the p-value is:

$$pvalue=max_{H_{0}}\{P(X=0)\}=\cfrac{\cfrac{(999)!}{(999-n)!}}{\cfrac{1000!}{(1000-n)!}}=\cfrac{1000-n}{1000}$$

You need a sample size n such that, when the observed value of X is 0, the p-value is less than or equal to the significance level $$\alpha$$. Taking $$\alpha$$=0.1:

$$\cfrac{1000-n}{1000}<=0.1$$

$$n>=900$$

If you find no defective products in a sample of 900 products, you can reject the null hypothesis $$H_{0}: K>0$$ with significance level 0.1.

• Thanks! It looks like it is going to be a bit hard to achieve, tho haha. Jan 16, 2023 at 16:30