Problem Statement
At a certain electronics factory, in a typical day’s output 10% percent of resistors are bad, and the rest are good. Good resistors have an 80% chance of passing the factory’s test, and bad resistors have a 30% chance of passing the test. Suppose the factory tests each resistor three times. If a particular resistor passes the test 2 times out of 3, what are the chances it is good?
Solution 1
First, let's define some events:
$B :=$ resistor is bad, $G :=$ resistor is good
$P :=$ resistor passes one test, $F :=$ resistor fails one test
$Q :=$ resistor passes 2 out of 3 tests
From the problem statement, we can say that $P[B] = 0.10, P[G] = 0.90, P[P|G] = 0.80, P[P|B] = 0.30$. Since the tests are independent, we can also say that $P[Q|G] = {3 \choose 2}(0.8)^2(0.2)$ and that $P[Q|B] = {3 \choose 2}(0.3)^2(0.7)$.
The quantity we seek is $P[G|Q]$. We proceed using Bayes' theorem:
$$ \begin{align} P[G|Q] &= \frac{P[Q|G]P[G]}{P[Q]}\\ &= \frac{P[Q|G]P[G]}{P[Q|G]P[G] + P[Q|B]P[B]}\\ &= \frac{{3 \choose 2}(0.8)^2(0.2)(0.9)}{{3 \choose 2}(0.8)^2(0.2){0.9} + {3 \choose 2}(0.3)^2(0.7)(0.1)}\\ &\approx 0.95 \end{align} $$
Solution 2
This solution is the same as solution 1, but we calculate $P[Q]$ differently. We can say that $P[P] = P[P|G]P[G] + P[P|B]P[B] = (0.8)(0.9) + (0.3)(0.1) = 0.75$. Since the tests are independent, $P[Q] = {3 \choose 2}(0.75)^2 (0.25)$.
We proceed using Bayes' theorem just like we did in solution 1:
$$ \begin{align} P[G|Q] &= \frac{P[Q|G]P[G]}{P[Q]}\\ &= \frac{{3 \choose 2}(0.8)^2(0.2)(0.9)}{{3 \choose 2}(0.75)^2 (0.25)}\\ &\approx 0.82 \end{align} $$
My Question
To me, both of these approaches seem right, but the answers are different. I've done the math several times, so I don't think the difference is due to an arithmetic error. Which solution is correct? Why?
The difference in the two approaches is in how you compute $P(Q)$. The first approach is the correct one.
(Let me write $Y$ instead of $P$ for "passing the test one time".) The second approach computes $P(Y)$ and then feeds it in the binomial distribution to derive the probability of passing the test twice out of three attempts. The flaw is in the assumption that the three trials are independent: the resistor is either good or bad (and the outcomes of the trials depend on its state).
Your second approach may be re-examined as follows. Let $Q$ be the event "passing the test two times out of three". Then $P[Q] = P[Q|G]P[G] + P[Q|B]P[B]$ as in your application of the Bayes' rule.