My homework question:
An inspector suspects that the food in the factory she is inspecting has been contaminated with a harmful chemical c. Such chemical contamination occurs in 5% of factories producing this food. The inspector has a test A for the chemical which registers positive with 100% certainty when the chemical is present, but the test also registers positive in 10% of cases where the chemical is not present. She decides to use this test to help her decide whether there is contamination.
- Assume that the prior probability of contamination is equal to the base rate, and that the inspector’s test shows a positive result. Compute the posterior probability of contamination.
- The inspector has another test B for chemical c which only registers positive 50% of the time when c is present, but has the advantage of never giving a false positive (i.e., if c is not present, the test will never say it is). The results of the two tests, A and B, are independent given the presence or absence of c. It turns out that when the inspector uses test B, the results are negative. In addition, the inspector knows that the factory is poorly maintained. The rate of contamination in factories with poor maintenance is twice as high as the rate in factories overall. Compute the posterior probability of contamination.
I know these should be rather basic, but I'm getting stuck. For #1 I've reached an answer, but I'm not sure it's correct:
Using Bayes rule the probability should be
$P(c|positive) = \frac{P(positive|c)P(c)}{P(positive)}$
Now I think that $P(positive)$ should be:
$P(positive) = P(positive,c)+P(positive,\neg c) = P(positive|c)P(c) + P(positive|\neg c)P(\neg c)$
Thus:
$P(c|positive) = \frac{P(positive|c)P(c)}{P(positive|c) P(c) + P(positive|\neg c) P(\neg c)}$
$P(c|positive) = \frac{1 * 0.05}{1 * 0.05 + 0.1 * 0.95} = 0.34$
Is this correct?
In part #2 I thought since they are supposed to be independent this must hold:
$ P(A_{positive} \cap B_{negative}|c) = P(A_{positive}|c)*P(B_{negative}|c) $
First I adjusted the base rate and recalculated #1:
$P(c|A_{positive}) = \frac{1 * 0.1}{1 * 0.1 + 0.1 * 0.9} = 0.52$
The questions says: "the results are negative". So B should be:
$P(c|B_{negative}) = \frac{P(B_{negative}|c)P(c)}{P(B_{negative}|c) P(c) + P(B_{negative}|\neg c) P(\neg c)} = \frac{0.5 * 0.1}{0.5 * 0.1 + 1 * 0.9} = 0.05$
$ P(c|A_{positive} \cap B_{negative}) = \frac{P(A_{positive} \cap B_{negative}|c) * P(c)}{P(A_{positive} \cap B_{negative})} = \frac{P(A_{positive}|c) * P(B_{negative}|c) * P(c)}{P(A_{positive} \cap B_{negative})} $
What should I do next?