# Combinatorics/Probability Problem

I have a problem where you are testing $5$ parts, $3$ work and $2$ don't work, but you don't know which are which. If $X$ is the number of parts that have to be tested to figure out which ones don't work, what are the values of $P$ and their probabilities.

Okay, so I figured once you test either $2$ bad parts or $3$ good parts you can stop testing and that the max you would have to do is $4$ tests, because once you test $4$ you automatically know what the last one is. So, if B denotes bad and G denotes good then $X=2$ can be BB, X=3 can be GGG, BGB, or GBB, and $X=4$ can be BGGB, GBGG, GGBG, GBGB, GGBB, or BGGB which is $11$ total possibilities (I'm pretty sure this is all of them). This is kinda where I'm stuck though, I'm not really sure how to find $P(X=2,3,4)$.

Can anyone help?

-

We test the items one at a time. The probability the first item tested is bad is $2/5$. Given that the first item tested was bad, the probability that the second item tested is bad is $1/4$ (only $1$ bad left, $4$ items left). So the probability the first two are bad is $(2/5)(1/4)$. Thus $P(X=2)=(2/5)(1/4)$.
For $P(X=3)$, we use your analysis. By the same sort of calculation as in the first paragraph, the probability of GGG is $(3/5)(2/4)(1/3)$. The probability of BGB is $(2/5)(3/4)(1/3)$. The probability of GBB is $(3/5)(2/4)(1/3)$ (this is the same as the probability of BGB, not an accident). Add up the three numbers.
For $P(X=4)$, it is easiest to use your observation that the only possible values of $X$ are $2$, $3$ and $4$. It follows that $P(X=4)=1-[P(X=2)+P(X=3)]$. Or else one can use calculations like those in the first two paragraphs, using your analysis of cases. It turns out to be less unpleasant than it looks. And it may be worth doing: the probabilities must add up to $1$, so doing an independent calculation of $P(X=4)$ provides a partial check on the correctness of the first two calculations.
Enumerate 5-letters words. As you explain, $[X=2]$ corresponds to BBGGG, $[X=3]$ to GGGBB, BGBGG and GBBGG, and $[X=4]$ to BGGBG, GBGGB, GGBGB, GBGBG, GGBBG, or BGGBG. The total number of words is 1+3+6=10 (that is, as was to be expected, 5-choose-2 as in five-positions-choose-two-B). If the letters at different positions are i.i.d. (even with a bias between B and G), all the 5-letters word with the same composition (here, two B and three G) have the same probability. Hence, $\mathrm P(X=2)=\frac1{10}$, $\mathrm P(X=3)=\frac3{10}$ and $\mathrm P(X=4)=\frac6{10}$,