A Bayesian Approach to Medical Diagnosis

Suppose that we know the following statistics about a city of one million people:

This means that if we could pick a random person and examine them thoroughly, that

Therefore an examination for abnormal moles could be used in screening for melanoma.

Note: The numbers above have been chosen to be plausible but not necessarily accurate.

If a patient comes to a dermatologist and asks to be examined for melanoma, the dermatologist's initial belief (before any examination) is P(M) = 0.001. If the patient is found to have an abnormal mole, the dermatologist's belief must now be updated to P(M|A) = P(A and M)/P(A) = 0.0002/0.1 = 0.002.

Note: The above scenario is oversimplified. Any well-trained dermatologist would also take into account at least the patient's age, gender, history, characteristics of the mole or moles, etc.

Suppose the dermatologist can perform a further test, T, that can come out positive (giving further evidence of melanoma) or negative, but is not completely accurate. The literature on the test gives the following:

How much difference would a positive outcome for the test make in the dermatologist's belief about P(M)?
In other words, what is P(M|A and (T=positive) )?

To calculate this, note that P(M|A and (T=positive) ) = P(M and A and (T=positive) )/P( A and (T=positive) )
by definition. The numerator can be evaluated as P(M and A) * P((T=positive) | M and A ) = 0.0002 * 0.95. The denominator can be broken into P( M and A and (T=positive) ) + P( (not M) and A and (T=positive) ), where the first term is 0.0002 * 0.95 as in the numerator. The second term can be evaluated as P(( not M) and A) * P((T=positive) | M and A ) = 0.0998 * 0.10, so

P(M|A and (T=positive) ) = (0.0002 * 0.95)/(0.0002 * 0.95 + 0.0998 * 0.10) = 0.0187..., so after getting a positive outcome from the test the probability of melanoma goes up from 0.002 to 0.0187...

Similarly, P(M|A and (T=negative) ) = P(M and A and (T=negative) )/P( A and (T=negative) )
= ( 0.0002 * 0.05 ) / ( 0.0002 * 0.05 + 0.0998 * 0.90) = 0.00011..., so after getting a negative outcome, the probability of melanoma goes down from 0.002 to 0.00011...