Test and probability / Bayes

There is a virus test with has 95% reliability.

This sentence is ambiguous. Reliability of a test is a mixture of Sensibility and Specificity.

Let's assume that you mean Sensitivity and Specificity both $95\%$

Thus the number of positive tests is

$$0.95\times 20,000+0.05\times 9,980,000=19,000+499,000=518,000$$

But only $19,000$ are actually positive, thus the PPV (Positive Predictive Value) is

$$PPV=\frac{19,000}{518,000}\approx 3.67\%$$

The result is not counterintuitive because the correct predictive value depends not only on the test reliability but also on the Virus prevalence in the population. That is the reason why mass test on all the population are not recommended.

Try the same exercise with a prevalence of 40% and realize that your PPV is about 93%.

For your exercise, the PPV obviously increases if you repeat the test and it is always positive

$$PPV(1)\approx 3.67\%$$

$$PPV(2)\approx 41.98\%$$

$$PPV(3)\approx 93.22\%$$

$$PPV(4)\approx 99.62\%$$

Where with $PPV(i)$ I mean the probability to have the virus after $i$ consecutive positive tests


$20000$ are sick of the virus and $9,980,000$ are not sick.

Test has $95\%$ reliability.

Out of $20,000$ sick people -

$19,000$ will test positive and $1000$ will test negative.

Out of $9,980,000$ healthy people,

$499,000$ will test positive and $9,481,000$ will test negative.

Unconditional probability of being sick $P(A) = 0.002$

Unconditional probability of testing positive $P(B) = \frac{499,000+19,000}{10,000,000} = 0.0518$

Probability of testing positive given the person is sick $P(B|A) = 0.95$

So probability of a person really being sick if tested positive,

$\, P(A|B) = \frac{0.95 \times 0.002}{0.0518} \approx 3.67\%$