# Derive the probability that Tom W is a computer scientist.

I'm reading Thinking, Fast and Slow by Daniel Kahneman and I came across the following text:

The following is a personality sketch of Tom W written during Tom's senior year in high school by a psychologist, on the basis of psychological tests of uncertain validity:

Tom W is of high intelligence, although lacking in true creativity. He has a need for order and clarity, and for neat and tidy systems in which every detail finds its appropriate place. His writing is rather dull and mechanical, occasionally enlivened by somewhat corny puns and flashes of imagination of the sci-fi type. He has a strong drive for competence. He seems to have little feel and little sympathy for other people, and does not enjoy interacting with others. Self-centered, he nonetheless has a deep moral sense.

The book then goes on to show that most people, when asked to estimate the probability that Tom W is enrolled in computer science and not some other field, only consider the above description in their judgment, and completely ignore the fact that there are far less students in computer science than there are in social studies. In order to give arrive at a better estimate, Kahneman proposes the use of Bayesian statistics:

The relevant "rules" for cases such as the Tom W problem are provided by Bayesian statistics. This influential modern approach to statistics is named after an English minister of the eighteenth century, the Reverend Thomas Bayes, who is credited with the first major contribution to a large problem: the logic of how people should change their mind in the light of evidence. Bayes' rule specifies how prior beliefs (in the examples of this chapter, base rates) should be combined with the diagnosticity of the evidence, the degree to which it favors the hypothesis over the alternative. For example, if you believe that $$3\%$$ of graduate students are enrolled in computer science (the base rate), and you also believe that the description of Tom W is $$4$$ times more likely for a graduate student in that field than in other fields, then Bayes' rule says you must believe that the probability that Tom W is a computer scientist is now $$11\%$$.

Question: Why would the posterior probability equal $$11\%$$? If $$A$$ is the event that Tom is a computer scientist, and $$B$$ is the event that a student has a description like Tom, Bayes' theorem says that $$P(A\mid B) = \dfrac{P(B\mid A)P(A)}{P(B)}$$ If we assume that the base rate is $$0.03$$ we have that $$P(A) = 0.03$$, and if we assume that the given description is four times as likely for a student enrolled in computer science than a student enrolled in any other field, we have that $$\dfrac{P(B\mid A)}{P(B)} = \dfrac{4P(B\mid C)}{5P(B\mid C)} = \dfrac{4}{5}$$ where $$C$$ is the event that Tom is not enrolled in computer science and using the fact that $$P(B) = P(B\mid A) + P(B\mid C)$$. Combining the prior and the likelihood we get that $$P(A\mid B) = \dfrac{4}{5}*0.03 = 0.024$$ What am I doing wrong?

EDIT: I know what I did wrong. It was incorrect for me to say that $$P(B) = P(B\mid A) + P(B\mid C)$$. It's supposed to be: $$P(B) = P(B\mid A)P(A) + P(B\mid C)P(C),$$ and this solves the problem. What should I do now? Answer the question myself, or edit it even more?

You need:

$$P(B)=P(B|A)\cdot P(A) + P(B|A^C)\cdot P(A^C)$$

and:

$$P(B|A) = 4 \cdot P(B|A^C)$$

So then:

$$P(A|B)=\frac{P(B|A)\cdot P(A)}{P(B)}=$$

$$\frac{P(B|A)\cdot P(A)}{P(B|A)\cdot P(A) + P(B|A^C)\cdot P(A^C)}=$$

$$\frac{4 \cdot P(B|A^C) \cdot 0.03}{4 \cdot P(B|A^C) \cdot 0.03 + P(B|A^C)\cdot 0.97}=$$

$$\frac{0.12 \cdot P(B|A^C)}{P(B|A^C)\cdot (0.12+ 0.97)}=$$

$$\frac{0.12 }{1.09}\approx 0.11$$

It is incorrect to say that $P(B) = P(B\mid A) + P(B\mid C)$. Instead $$P(B) = P(B\mid A)P(A) + P(B\mid C)P(C)$$ Since $P(A) = 0.03$ and $A^c = C$ we have that $P(C) = 0.97$. Hence $$P(B) = 0.03P(B\mid A) + 0.97P(B\mid C) = 0.03 * 4P(B\mid C) + 0.97P(B\mid C) = 1.09P(B\mid C).$$ This means that we have that $$\dfrac{P(B\mid A)}{P(B)} = \dfrac{4P(B\mid C)}{1.09P(B\mid C)} = 3.6697$$ and $$P(A\mid B) = 3.6697*0.03 = 0.11$$