For the same Conditional Probability, why does Bayes's Theorem differ from a direct calculation?

125 Views Asked by At

Abbreviate: $D =$ a person is diseased, $+ =$ the test is positive.
Assume: $\Pr(D) = 0.001, \; \Pr(+|D)=0.99, \; \Pr(+|D^C) = 0.01 \qquad ($$\iff$ $ \Pr(-|D^C) = 0.99).$

1. Use Bayes's Theorem: $\Pr(D|+) = 0.0 \; 90 \; 1639... \quad $ (confirmed; scroll down 30% hereof).

2. Quantify the above probabilities for 1000 people (per 1 and 2)
(Table herefrom. Green indicates True results, red False results).

$$\begin{array}{r|cc|c} &D &\lnot D &\text{Total}\\ \hline +&\color{green}{\Pr(D)\Pr(+|D)}&\color{red}{\Pr(D^C)\Pr(+|D^C)}&\text{add the 2 left entries}\\ - &\color{red}{\Pr(D)\Pr(-|D)}&\color{green}{\Pr(D^C)\Pr(-|D^C)}&\color{black}{\text{add the 2 left entries}}\\ \hline \text{Total}&\color{black}{1}&\color{black}{999}&\color{black}{1000} \end{array}$$

$$\begin{array}{r|cc|c} &D &\lnot D &\text{Total}\\ \hline +&\color{green}{1}&\color{red}{9.99}&10.99\\ - &\color{red}{\text{impertinent}}&\color{green}{\text{impertinent}}&\color{black}{\text{impertinent}}\\ \hline \text{Total}&\color{black}{1}&\color{black}{999}&\color{black}{1000} \end{array}$$

$3.$ So $\Pr(D|+) = \dfrac{ \color{green}{1} }{ 10.99 } = 0.0 \; 90 \; 9918... \quad $

Why do 1 and 3 differ starting at the ten-thousandth digit?

2

There are 2 best solutions below

2
On BEST ANSWER

As mentioned in the comments, this is due to roundoff error. Try instead using $100000$ people:

$$\begin{array}{r|cc|c} &D &\lnot D &\text{Total}\\ \hline +&\color{green}{99}&\color{red}{999}&1098\\ - &\color{red}{1}&\color{green}{98901}&\color{black}{98902}\\ \hline \text{Total}&\color{black}{100}&\color{black}{99900}&\color{black}{100000} \end{array}$$

So: $$ \Pr[D \mid +] = \frac{99}{1098} = \frac{11}{122} = 0.090163934\ldots $$

0
On

Thanks to user 'Adriano' 's answer, I recognised the problem: I neglected to calculate precisely the four numbers in the middle entry which should instead be:

$$\begin{array}{r|cc|c} &D &\lnot D &\text{Total}\\ \hline +&\color{green}{0.99}&\color{red}{9.99}&10.98\\ - &\color{red}{ 0.01 }&\color{green}{989.01}&\color{black}{\text{989.02}}\\ \hline \text{Total}&\color{black}{1}&\color{black}{999}&\color{black}{1000} \end{array}$$

$3.$ So $\Pr(D|+) = \dfrac{ \color{green}{0.99} }{ 10.98 } = 0.0 \; 90 \; 1639344... \quad $