# Example:Medical test

Suppose a patient takes a medical test to see if they have a rare disease. The disease is rare: only 1/10,000 people have it. The test has a very good false positive rate of 1% (that is, of the people who don't have the disease, 1% of them still test positive) and a false negative rate of 2% (of the people who do have the disease, 2% of them test negative).

If a patient takes the test and gets a positive result, what is the probability that they have the disease?

We can model this problem probabilistically. Let represent the event where the patient has the disease, and let be the event where the patient is healthy. Let be the event representing a positive test result, and let be the event that the test is negative.

We can interpret the facts from the problem:

- the disease is rare: therefore ). (and
- the false positive rate is 1%: .
- the false negative rate is 2%: .

We are interested in the probability that the patient has the disease, given that they tested positive. In other words, we want to find .

We can apply Bayes' rule and the law of total probability (since and partition the sample space):

We need , in other words, what is the probability that the test results are positive, given that someone has the disease. Intuitively, this should be 98% (1 - Pr(N|D)). And indeed it is. You can prove this using the fact that conditional probabilities satisfy Kolmogorov's axioms.

Plugging this in, we get

Perhaps this is surprising; you might expect that a positive result on a good test means you have the disease with high probability. And indeed, you have learned a great deal: your chances of having the disease went up by a factor of 10. However, because the disease is still rare, you are still not particularly likely to have it.

However, you might want to have further testing done; see the repeated medical test example.