Finding $P(A|B)$ with conditional probability formula Suppose I have the following events:


*

*Event A: Contracted HIV

*Event B: Tested Positive with HIV


Given $1$ in $1000$ people gets contracted with HIV and the HIV Test gives a wrong test result for $1$ in $100$ people. If a person is tested Positive with HIV, I need to find the probability of him really contracted with HIV.
So I need to find $P(A|B)$ and that $P(A|B)=\frac{P(B|A) \cdot P(A)}{P(B)}$.
To find $P(B)$, I need to find all that are tested positive. So...
$P(B)=\frac{1}{1000} \cdot \frac{99}{100}+\frac{999}{1000} \cdot \frac{1}{100}=\frac{1098}{100000}$
$P(B|A)=\frac{1}{1000} \cdot \frac{99}{100}=\frac{99}{100000}$
$P(A)=\frac{1}{1000}$
Therefore, $P(A|B)=\frac{P(B|A) \cdot P(A)}{P(B)}=\frac{\frac{99}{100000}\cdot \frac{1}{1000}}{\frac{1098}{100000}}=\frac{11}{122000}=0.0000901639=0.009016\%$
While this may seem ok to me at first, I suspected my answer to be wrong because $0.009016\%$ as a figure is a little hard to believe. I did a search on the internet and looks like the answer could be just $ \frac{99}{1098} = 9.016\% $.
Is my initial answer wrong? What has gone wrong with my initial answer of $0.009016\%$? I simply followed the Bayes' Conditional formula.
 A: For convenience, let's say that there are 100,000 people (why I chose 100,000 will hopefully be clear shortly).  Since you said 1 in 1000 people has HIV, of our 100,000 people, 100 have HIV and 99,900 do not.  Since the HIV test returns an incorrect result 1 in 100 times: of the 100 HIV-positive people, 99 will test positive and 1 will test negative; of the 99,900 HIV-negative people, 98,901 will test negative and 999 will test positive.  Making a chart:
                  HIV-positive      HIV-negative      total
tests positive           99               999         1,098
tests negative            1            98,901        98,902
         total          100            99,900       100,000

Now, you wanted the probability that a person who tests positive is actually HIV-positive.  1,098 people tested positive and of those, only 99 were HIV-positive.  $$\frac{99}{1098}=\frac{11}{122}\approx 9.01639\%$$
As stated in comments, it's your $P(B|A)$ that's off.  $P(B|A)$ is the probability that an HIV-positive person tests positive—in the table above, there are 100 HIV-positive people and 99 test positive, so $$P(B|A)=\frac{99}{100}.$$
You might consider an alternate formula for the conditional probability: $$P(A|B)=\frac{P(A\text{ and }B)}{P(B)}.$$
$P(A\text{ and }B)$ is the probability of a person testing positive and being HIV-positive, which is the 99 out of 100,000 that you computed, so $$P(A|B)=\frac{P(A\text{ and }B)}{P(B)}=\frac{\frac{99}{100000}}{\frac{1098}{100000}}=\frac{99}{1098}=\frac{11}{122}\approx 9.01639\%.$$
