Suppose

is the event that a given patient has the disease, and

is the event of a positive test result.
We're given that



where

denotes the complement of an event

.
a. We want to find

. By the law of total probability, we have

That is, in order for

to occur, it must be the case that either

also occurs, or

does. Then from the definition of conditional probability we expand this as

so we get

b. We want to find

. Now, we can use Bayes' rule, but if you're like me and you find the formula a bit harder to remember, we can easily derive it.
By the definition of conditional probability,

We have the probabilities of

/

occurring given that

/

occurs, but not vice versa. However, we can expand the probability in the numerator to get a probability in terms of

being conditioned on

:

Meanwhile, the law of total probability lets us rewrite the denominator as

or in terms of conditional probabilities,

so that

which is exactly what Bayes' rule states. So we get
