Conditional probability of someone being a terrorist, based on the output of a prevention system I've come up with a solution to this book exercise. My answer is different to the one given by the book by exactly one order of magnitude, unfortunately I can't figure out what I'm doing wrong.
The exercise statement (roughly):
Assume there is a terrorist prevention system that has a 99% chance of correctly identifying a future terrorist and 99.9% chance of correctly identifying someone that is not a future terrorist. If there are 1000 future terrorists among the 300 million people population, and one individual is chosen randomly from the population, then processed by the system and deemed a terrorist. What is the chance that the individual is a future terrorist?
Attempted exercise solution:
I use the following event labels:


*

*A -> The person is a future terrorist 

*B -> The person is identified as a terrorist


Then, some other data:
$$P(A) = \frac{10^3}{3\cdot10^8} = \frac{1}{3 \cdot 10^5} $$
$$P(\bar{A}) = 1 - P(A)$$
$$P(B\mid A) = 0.99$$
$$P(\bar{B}\mid A) = 1 - P(B\mid A)$$
$$P(\bar{B}\mid \bar{A}) = 0.999$$
$$P(B\mid \bar{A}) = 1 - P(\bar{B}\mid \bar{A})$$
What I need to find is the chance that someone identified as a terrorist, is actually a terrorist. I express that through $P(A\ |\ B)$ and use Bayes Theorem to find its value.
$$
P(A\mid B) = \frac{P(A\cap B)}{P(B)} = \frac{P(B\mid A)\cdot P(A)}{P(B\mid A)\cdot P(A) + P(B\mid \bar{A})\cdot P(\bar{A})}
$$
The answer I get after plugging-in all the values is: $3.29 \cdot 10^{-3}$, the book's answer is $3.29 \cdot 10^{-4}$
Can someone help me identify what I'm doing wrong? Also, in either case, I find that it is very unintuitive that the probability of success is so small. If someone could explain it to me in more intuitive terms I'd be very grateful.
Thank you!
 A: Let's look at the $2 \times 2$ table, but first, let's rewrite the notation so that it is unambiguous what the events mean.  Let $F$ be the event that a randomly chosen individual from the population is a future terrorist.  Let $T$ be the event that a randomly chosen individual from the population tests positive as a terrorist.  Then $$\begin{array}{c|c|c|c} & T & \bar T & \\ \hline F & 990 & 10 & 1000 \\ \hline \bar F & 299999 & 299699001 & 299999000\\ \hline & 300989 & 299699011 & 300000000 \end{array}$$ gives the cell frequencies for the entire population.  This is found by observing, for instance, that if there are $1000$ future terrorists in the population, then a test that has a $99\%$ correct positive rate means that $(0.99)(1000) = 990$ of these $1000$ future terrorists would also test positive, and the remaining $10$ would be false negatives (future terrorists that the test misses).  Similarly, a test that has a $99.9\%$ correct negative rate means that $(0.999)(300 \times 10^6 - 1000)$ non-terrorists are correctly identified as such.  Then the column totals are computed for $T$ and $\bar T$.
Now it is a trivial exercise to compute the conditional probability $\Pr[F \mid T]$:  This is simply $$990/300989 = 0.00328916.$$  The book is incorrect.
What this exercise demonstrates is that when the prevalence of a particular trait is rare in a population, a diagnostic test to detect whether that trait exists in a randomly selected person must have extremely high specificity in order to have high positive predictive value.  The problem, as you can see from the table, is that the group of positive-testing non-terrorists $T \cap \bar F$ is much, much larger than the population of terrorists.  Even if the test is $100\%$ sensitive--i.e., it never gives a false negative--all that would do is make the first row $1000$, $0$, $1000$.  The number of false positives is $299999$, which is overwhelming.  You need a test that will have such a high specificity that the chance of incorrectly identifying someone as a terrorist is very, very unlikely.  This situation clearly has ramifications for screening tests for rare diseases, such as HIV:  a test is unlikely to be simultaneously cost-effective and highly specific, that you would mitigate the false positive rate.  Obviously, you really do not want to make available an HIV test that would give such a high false positive rate--it would be emotionally devastating for numerous people, not to mention it would cause anger and suspicion toward the usefulness of testing.
A: The books answer is likely a typographical error.  Your calculation is correct.
The smallness of the value should not be surprising.   Despite the seeming accuracy of the test (more correctly the sensitivity and specificity of the test), the expected number of people giving false positive responses ($299\,999$) is still be significantly higher than that of people giving true positive responses ($990$).
An accurate test of something with a rather small prevalence requires an appropriate degree of specificity.   A $0.1\%$ true negative rate is just not specific enough to test something with only a $0.0003\%$ prevalence. 
