So I'm trying to wrap my mind around Bayes' theorem
. No, this is not my homework.
Let's take the following data:
1 in 1000 people get a disease.
A mandatory test for it has 95% certainty -- it will correctly give a positive result 95% of the time and correctly give a negative result 95% of the time.
If you get a positive result, what are the odds that you actually have the disease?
Right. Stop me if you see me doing something wrong.
P(d) = probability to have the disease. One in a thousand = P(d) = 0.001.
P(n) = probability to not have the disease = 1 - P(d) = 0.999.
P(p|d) = probability to have the disease and get a positive result. 95% certain test = 0.95.
P(p|n) = probability to NOT have the disease and get a positive result. 5% error margin = 0.05.
P(p) = the probability to get a positive result regardless of other facts.
The probability of having the disease and getting a positive result = 0.001 * 0.95 = 0.00095.
The probability to NOT have it and still get a positive result = 0.999 * 0.05 = 0.04995.
Add those up and we get P(p) = 0.0509.
Right. Bayes' theorem states:
I want the probability to have the disease if I get a positive result, or P(d|p). So, hooking the numbers into the theorem...
P(d|p) = (P(p|d) * P(d)) / P(p)
P(d|p) = (0.95 * 0.001) / 0.0509
P(d|p) = 0.0186640472
So, ~1.87% chance to have the disease if I get a positive result. Did I do this right?
Let they who have not posted about their balls in the wrong thread cast the first stone.