# Bayes' theorem : lie-detector machine

Assuming there is lie-detector which can find out 95% of all lies correctly and of all true statements classifies 98% as true. Now we know that only one person would lie among 300. If the detector says a person is lying, what is the probability that this person is lying?

Assuming that X = {person is lying}, D = {detector finds a lie}, then we need to know p(X|D) given that p(X) = 1/300. Now I'm stuck with the meaning of 95% and 98%, is p(D|X) = 0.95*0.98?

• $P(D|X)=0.95$ and $P(\neg D|\neg X)=0.98$ – John Douma Jan 18 '19 at 18:25
• @John Douma Can you help check if my thinking is right or not ? $$p(X|D) = p(X,D)/p(D) = \frac{p(D|X)p(X)}{p(D|X)p(X)+p(D|\bar{X})p(\bar{X}) = (0.95*1/300)/(0.95*1/300+ 0.02*299/300)= ..$$ – Jiayan Yang Jan 18 '19 at 18:55
• @JiayanYang Yes, that is exactly correct – Bram28 Jan 18 '19 at 19:11
• Yes, it looks good. Thanks @Bram28. – John Douma Jan 18 '19 at 21:10

Using your notation for events, $$X$$ and $$D$$ represent the events that a person is lying, and a lie is detected, respectively. let $$\bar X$$ and $$\bar D$$ represent the complementary events; namely, a person tells the truth, and a lie is not detected, respectively.
We are given $$\Pr[D \mid X] = 0.95, \quad \Pr[\bar D \mid \bar X] = 0.98, \quad \Pr[X] = \frac{1}{300}.$$ We want to compute $$\Pr[X \mid D]$$, the conditional probability that, given the detector indicates a lie, that the person actually lied. Bayes' rule gives
$$\Pr[X \mid D] = \frac{\Pr[D \mid X]\Pr[X]}{\Pr[D]},$$ the numerator of which is already known. The denominator, the unconditional probability of a lie being detected, is found by an application of the law of total probability:
$$\Pr[D] = \Pr[D \mid X]\Pr[X] + \Pr[D \mid \bar X]\Pr[\bar X].$$
The first term is the same as the numerator. The second term is computed by noting $$\Pr[\bar X] = 1 - \Pr[X], \\ \Pr[D \mid \bar X] = 1 - \Pr[\bar D \mid \bar X].$$ Therefore, in terms of the given probabilities, we have
$$\Pr[X \mid D] = \frac{\Pr[D \mid X]\Pr[X]}{\Pr[D \mid X]\Pr[X] + (1 - \Pr[\bar D \mid \bar X])(1 - \Pr[X])}.$$