*See also: numbers, Permutations and Combinations*

**Bayes' Theorem**, named after Rev. Thomas Bayes, describes the relationship between the conditional probability of two events $A$ and $B$ as follows:

or

$$\mathbb{P}(A\mid B)=\frac{\mathbb{P}(B\mid A)\mathbb{P}(A)}{\mathbb{P}(B\mid A)\mathbb{P}(A)+\mathbb{P}(B\mid \stackrel{\u203e}{A})\mathbb{P}(\stackrel{\u203e}{A})}$$*Example:*

In a certain country, it is known that 2% of the population suffer from a certain disease. A clinical test yields a correct positive result of a person carrying the disease 97% of the cases. However, when a person not carrying the disease is subjected to the same test, 9% of all the cases, the test will yield a false positive result.

If a random person from that country takes the test and get a positive result, what is the probability that he is really carrying the disease?

Intuitively, we may think that there's a very good chance that he's carrying the disease, since the test yield 97% correct positive result. However, let's look at the math.

Let us represent the information above as follows:

- $B$ = The event that the test yields a positive result.
- $\stackrel{\u203e}{B}$ = The event that the test yields a negative result.
- $A$ = The event that a person is carrying the disease
- $\stackrel{\u203e}{A}$ = The event that a person is not carrying the disease.

We also know the following probabilities:

- $\mathbb{P}(A)=2\%$
- $\mathbb{P}(\stackrel{\u203e}{A})=98\%$
- $\mathbb{P}(B\mid A)=97\%$
- $\mathbb{P}(B\mid \stackrel{\u203e}{A})=9\%$

Using the formula for conditional probability, we can then summarize the probabilities of the events in the following table:

$A$ (2%) | $\stackrel{\u203e}{A}$ (98%) | |
---|---|---|

$B$ | True Positive $$\begin{array}{rl}\mathbb{P}(B\cap A)& =\mathbb{P}(A)\times \mathbb{P}(B\mid A)\\ & =2\%\times 97\%\\ & =1.94\%\end{array}$$ | False Positive $$\begin{array}{rl}\mathbb{P}(B\cap \stackrel{\u203e}{A})& =\mathbb{P}(\stackrel{\u203e}{A})\times \mathbb{P}(B\mid \stackrel{\u203e}{A})\\ & =98\%\times 9\%\\ & =8.82\%\end{array}$$ |

$\stackrel{\u203e}{B}$ | False Negative $$\begin{array}{rl}\mathbb{P}(\stackrel{\u203e}{B}\cap A)& =\mathbb{P}(A)\times \mathbb{P}(\stackrel{\u203e}{B}\mid A)\\ & =2\%\times 3\%\\ & =0.06\%\end{array}$$ | True Negative $$\begin{array}{rl}\mathbb{P}(\stackrel{\u203e}{B}\cap \stackrel{\u203e}{A})& =\mathbb{P}(\stackrel{\u203e}{A})\times \mathbb{P}(\stackrel{\u203e}{B}\mid \stackrel{\u203e}{A})\\ & =98\%\times 91\%\\ & =89.18\%\end{array}$$ |

Now, suppose a person was tested positive, what is the probability that he is really carrying the disease?

In other words, we are trying to find the probability of $A$, given $B$ or $\mathbb{P}(A\mid B)$.

From the table above, we can see that $\mathbb{P}(A\mid B)$ is really the probability of true positive divided by the probability of getting any positive result. That is

$$\frac{1.94\%}{1.94\%+8.82\%}=18.03\%$$We can also get this result by using the above Bayes' Theorem formula:

$$\begin{array}{rl}\mathbb{P}(A\mid B)& =\frac{\mathbb{P}(B\mid A)\mathbb{P}(A)}{\mathbb{P}(B\mid A)\mathbb{P}(A)+\mathbb{P}(B\mid \stackrel{\u203e}{A})\mathbb{P}(\stackrel{\u203e}{A})}\\ & =\frac{97\%\times 2\%}{(97\%\times 2\%)+(9\%\times 98\%)}\\ & =\frac{1.94\%}{1.94\%+8.82\%}\\ & =\frac{1.94\%}{10.76\%}\\ & =18.03\%\end{array}$$This result may seems counter-intuitive. The probability that the person tested positive is actually carrying the disease is not as high as we may think. There's only about 18% chance that the person is really carrying the disease.

Why is this so?

In estimating the probability, we often forget that the percentage of the population carrying the disease is small in the first place (i.e. only 2% of the population suffers the disease). So even though the test is highly accurate for people with the disease, it doesn't mean that if the person is tested positive, there will be a high chance that he or she is really carrying the disease.

We can look at it this way. Suppose there are only 1000 people in that country. Only 20 people suffer the disease (2%). 19 of those 20 will get a positive test result (97% true positive result). Of the other 980 people not suffering the disease, about 88 people (9% false positive result) will also get positive test result.

So from the 1000 people, we can group them as follows

- 19 people get true positive results
- 1 person gets false negative result
- 88 people get false positive results
- 892 people get true negative results

From the above, we gather that about (88 + 19) = 107 people will get positive results (regardless of whether they suffer the disease or not). From these 107, how many of them are really carrying the disease? Only 19 out of 107 (or about 18%).

*See also: numbers, Permutations and Combinations*