User:Zvika/sandbox

Suppose someone told you they had a nice conversation with someone on the train. Not knowing anything else about this conversation, the probability that they were speaking to a woman is 50%. Now suppose they also told you that this person had long hair. It is now more likely that they were speaking to a woman, since most long-haired people are women. Bayes' theorem is used to calculate the probability that the person is a woman.

To see how this is done, let $$W$$ represent the event that the conversation was held with a woman, and let $$L$$ denote the event that the conversation was held with a long-haired person. Women constitute half the population, so, not knowing anything else, the probability that $$W$$ occurs is $$\Pr(W) = 0.5$$. Suppose it is also known that 75% of women have long hair, which we denote as $$\Pr(L|W) = 0.75$$ (read: the probability of event $$L$$ given event $$W$$ is 0.75). Likewise suppose it is known that 30% of men have long hair, or $$\Pr(L|M) = 0.3$$, where $$M$$ is the complementary event of $$W$$, i.e., the event that the conversation was held with a man.

Our goal is to calculate the probability that the conversation was held with a woman, given the fact that the person had long hair, or, in our notation, $$\Pr(W|L)$$. Using the formula for Bayes' theorem, we have
 * $$\Pr(W|L) = \frac{\Pr(L|W) \Pr(W)}{\Pr(L)} = \frac{\Pr(L|W) \Pr(W)}{\Pr(L|W) \Pr(W) + \Pr(L|M) \Pr(M)}$$

where we have used the law of total probability. The numeric answer can be obtained by substituting the above values into this formula. This yields $$\Pr(W|L) \approx 0.714$$, i.e., the probability that the conversation was held with a woman, given that the person had long hair, is about 71%.