Sampling 100 widgets to test for defective ones

Given a 100 widgets. The probability of a widget being defective is $\frac{1}{2}$. Let

$A$ be the event that $k$ sampled widgets are all functioning properly, for $0\leq k\leq 100$.

$B$ be the event that $6$ or more of the $100$ widgets are defective.

What is the minimum number of widgets $k$ which must be sampled to ensure that $P(A\cap B)< .1$

We can write $P(A\cap B)=P(A\cap (B_6\;\cup ...\cup\; B_{100})\;)$. Where $B_i$ is the event that exactly $i$ widgets are defective. Now since the $B_i$ are disjoint, we can write this as

$$P(\; (A\cap B_6)\;\cup ...\cup\;(A\cap B_{100})\;)=\sum_{i=6}^{100}P(A\cap B_i)=\sum_{i=6}^{100}P(A \mid B_i)P(B_i).$$

Now by the hypergeometric distribution we know that $$P(A\mid B_i)=\frac{\binom{100-i}{k}}{\binom{100}{k}}\;.$$ And $$P(B_i)=\frac{\binom{100}{i}}{2^{100}}\;.$$ Thus we obtain

$$\sum_{i=6}^{100}P(A \mid B_i)P(B_i)=\sum_{i=6}^{100}\frac{\binom{100-i}{k}}{\binom{100}{k}}\frac{\binom{100}{i}}{2^{100}}=\frac{1}{2^{100}}\sum_{i=6}^{100}\binom{100-k}{i}\;.$$

However the answer in the back of the book is $k=32$ which when I plug that into my formula gives me a number which is far too small to be correct. Have I gone wrong somewhere in my reasoning?

-
First small detail: the summation should stop at $100-k$ (for $i > 100-k$, the probability of choosing $k$ good'' widgets amongst $100-i<k$ ones is $0$). – Clement C. Jul 21 '13 at 0:39
@ClementC. the summation can go on to $100$ since as you say once it passes $100-k$ it no longer contributes anything. – esproff Jul 21 '13 at 0:54

Given the probability of a widget being defective being $\frac 12, P(B)$ is very close to $1$. Let's just concentrate on getting $P(A) \lt 0.1$ Now each widget is a coin flip, so even four tests give a chance of $\frac 1{16}$ of none being defective. $k=32$ is clearly wrong. The binomial approximation gives a standard deviation of $\sqrt{100(\frac 12)^2}=5$, so at the 2 SD level there are at least $40$ defectives and we need only have $0.6^k \lt 0.1$ which requires $k \gt 4.5$

-
Yah my formula gives $k=4$ (probably accounting for the fact that $P(B) < 1$), so it's far more in agreement with your estimate. So it looks like my book is in error then, thanks. – esproff Jul 21 '13 at 0:42

Depending on how you do the sampling (here, you seem to assume without replacement*), the answer should change. Assuming each sample is drawn i.i.d (with replacement), you get $$\mathbb{P}A\cap B = \sum_{b=6}^{100} \left(1-\frac{b}{100}\right)^k \frac{\binom{100}{b}}{2^{100}}$$ which also appears to yield $k\geq 4$.

*I first thought you had a mistake because of this, hence the rest of the derivation with another assumption on the sampling.

-
The sampling is done without replacement since I won't be checking the same widget for defectiveness multiple times. – esproff Jul 21 '13 at 0:55
I understand — see the "footnote" for the reason of iid sampling (as in your original post, you didn't specify whether the book chose with or without replacement). Out of curiosity, which book does this come from? – Clement C. Jul 21 '13 at 0:59
statistical inference 2nd edition exercise 3.2, the answer isn't actually in the book, I found a (apparently less than perfect) pdf of solutions online. – esproff Jul 21 '13 at 1:02
I just had a look at the pdf (is it the right one?). They (a) seem to consider only the case with exactly $6$ defective widgets (given their formula), and (b) furthermore forget to take into account the probability of getting $6$ defective widgets out of $100$ (i.e., event $B_6$). – Clement C. Jul 21 '13 at 1:19
Yah that's right. I believe their reasoning would have been correct if the $P(B_i)$ were uniform for all $i$, but since $P(B_6)$ is very small compared to $i$'s closer to $50$, their reasoning isn't correct. – esproff Jul 21 '13 at 2:05