Suppose
![D](https://tex.z-dn.net/?f=D)
is the event that a given patient has the disease, and
![P](https://tex.z-dn.net/?f=P)
is the event of a positive test result.
We're given that
![\mathbb P(D)=0.01](https://tex.z-dn.net/?f=%5Cmathbb%20P%28D%29%3D0.01)
![\mathbb P(P\mid D)=0.98](https://tex.z-dn.net/?f=%5Cmathbb%20P%28P%5Cmid%20D%29%3D0.98)
![\mathbb P(P^C\mid D^C)=0.95](https://tex.z-dn.net/?f=%5Cmathbb%20P%28P%5EC%5Cmid%20D%5EC%29%3D0.95)
where
![A^C](https://tex.z-dn.net/?f=A%5EC)
denotes the complement of an event
![A](https://tex.z-dn.net/?f=A)
.
a. We want to find
![\mathbb P(P^C)](https://tex.z-dn.net/?f=%5Cmathbb%20P%28P%5EC%29)
. By the law of total probability, we have
![\mathbb P(P^C)=\mathbb P(P^C\cap D)+\mathbb P(P^C\cap D^C)](https://tex.z-dn.net/?f=%5Cmathbb%20P%28P%5EC%29%3D%5Cmathbb%20P%28P%5EC%5Ccap%20D%29%2B%5Cmathbb%20P%28P%5EC%5Ccap%20D%5EC%29)
That is, in order for
![P^C](https://tex.z-dn.net/?f=P%5EC)
to occur, it must be the case that either
![D](https://tex.z-dn.net/?f=D)
also occurs, or
![D^C](https://tex.z-dn.net/?f=D%5EC)
does. Then from the definition of conditional probability we expand this as
![\mathbb P(P^C)=\mathbb P(D)\mathbb P(P^C\mid D)+\mathbb P(D^C)\mathbb P(P^C\mid D^C)](https://tex.z-dn.net/?f=%5Cmathbb%20P%28P%5EC%29%3D%5Cmathbb%20P%28D%29%5Cmathbb%20P%28P%5EC%5Cmid%20D%29%2B%5Cmathbb%20P%28D%5EC%29%5Cmathbb%20P%28P%5EC%5Cmid%20D%5EC%29)
so we get
![\mathbb P(P^C)=0.01\cdot0.02+0.99\cdot0.95=0.9407](https://tex.z-dn.net/?f=%5Cmathbb%20P%28P%5EC%29%3D0.01%5Ccdot0.02%2B0.99%5Ccdot0.95%3D0.9407)
b. We want to find
![\mathbb P(D\mid P)](https://tex.z-dn.net/?f=%5Cmathbb%20P%28D%5Cmid%20P%29)
. 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,
![\mathbb P(D\mid P)=\dfrac{\mathbb P(D\cap P)}{\mathbb P(P)}](https://tex.z-dn.net/?f=%5Cmathbb%20P%28D%5Cmid%20P%29%3D%5Cdfrac%7B%5Cmathbb%20P%28D%5Ccap%20P%29%7D%7B%5Cmathbb%20P%28P%29%7D)
We have the probabilities of
![P](https://tex.z-dn.net/?f=P)
/
![P^C](https://tex.z-dn.net/?f=P%5EC)
occurring given that
![D](https://tex.z-dn.net/?f=D)
/
![D^C](https://tex.z-dn.net/?f=D%5EC)
occurs, but not vice versa. However, we can expand the probability in the numerator to get a probability in terms of
![P](https://tex.z-dn.net/?f=P)
being conditioned on
![D](https://tex.z-dn.net/?f=D)
:
![\mathbb P(D\cap P)=\mathbb P(D)\mathbb P(P\mid D)](https://tex.z-dn.net/?f=%5Cmathbb%20P%28D%5Ccap%20P%29%3D%5Cmathbb%20P%28D%29%5Cmathbb%20P%28P%5Cmid%20D%29)
Meanwhile, the law of total probability lets us rewrite the denominator as
![\mathbb P(P)=\mathbb P(P\cap D)+\mathbb P(P\cap D^C)](https://tex.z-dn.net/?f=%5Cmathbb%20P%28P%29%3D%5Cmathbb%20P%28P%5Ccap%20D%29%2B%5Cmathbb%20P%28P%5Ccap%20D%5EC%29)
or in terms of conditional probabilities,
![\mathbb P(P)=\mathbb P(D)\mathbb P(P\mid D)+\mathbb P(D^C)\mathbb P(P\mid D^C)](https://tex.z-dn.net/?f=%5Cmathbb%20P%28P%29%3D%5Cmathbb%20P%28D%29%5Cmathbb%20P%28P%5Cmid%20D%29%2B%5Cmathbb%20P%28D%5EC%29%5Cmathbb%20P%28P%5Cmid%20D%5EC%29)
so that
![\mathbb P(D\mid P)=\dfrac{\mathbb P(D)\mathbb P(P\mid D)}{\mathbb P(D)\mathbb P(P\mid D)+\mathbb P(D^C)\mathbb P(P\mid D^C)}](https://tex.z-dn.net/?f=%5Cmathbb%20P%28D%5Cmid%20P%29%3D%5Cdfrac%7B%5Cmathbb%20P%28D%29%5Cmathbb%20P%28P%5Cmid%20D%29%7D%7B%5Cmathbb%20P%28D%29%5Cmathbb%20P%28P%5Cmid%20D%29%2B%5Cmathbb%20P%28D%5EC%29%5Cmathbb%20P%28P%5Cmid%20D%5EC%29%7D)
which is exactly what Bayes' rule states. So we get