# Probability using Bayes formula

Two masked robbers try to rob a crowded bank during the lunch hour but the teller presses a button that sets off an alarm and locks the front door. The robbers, realizing they are trapped, throw away their masks and disappear into the chaotic crowd. Confronted with $40$ people claiming they are innocent, the police give everyone a lie detector test. Suppose that guilty people are detected with probability $0.95$, and innocent people appear to be guilty with probability $0.01$. What is the probability that Mr. Jones is guilty given that the lie detector says he is?

The answer is $\frac{5}{6}$, but i don't know how they arrived at that.

Let $P$ denote the answer.

We have $$P= \frac {\frac 2{40}\times .95}{ \frac {38}{40}\times .01+\frac 2{40}\times .95}=\frac {2\times 95}{38+2\times 95}=\frac 56$$

Using Bayes's rule, we can write $$\mathbb{P}(B\mid A)=\frac{\mathbb{P}(A\mid B)\mathbb{P}(B)}{\mathbb{P}(A)}=\frac{\mathbb{P}(A\mid B)\mathbb{P}(B)}{\mathbb{P}(A\mid B)\mathbb{P}(B)+\mathbb{P}(A\mid B^c)\mathbb{P}(B^c)}$$ where $B^c$ is the complement of $B$.

In your problem, let $A$ be the event that the lie detector reports that Mr. Jones is guilty, and $B$ the event that Mr. Jones is in fact guilty. Based on the information in the problem, what are $\mathbb{P}(A\mid B), \mathbb{P}(A\mid B^c), \mathbb{P}(B)$, and $\mathbb{P}(B^c)$?

Bayes theorem is used for making inference about the cause, given we observe certain effect.

For your problem, it's better to construct a tree to get a clear picture.

2 people out of 40 are guilty. Therefore a person picked at random will be guilty 2/40 and innocent with 38/40. Given the we picked the guilty person there is .95 probability for the detector to identify him as guilty. On the other hand had we picked an innocent guy, the detector can mistakenly report him as guilty with probability 0.01

The question is to find the top most tree. This can be done using bayes theorem

Bayes theorem