I've tried to apply Bayes theorem to the following question, but I think I'm using it wrong.
2000 people take an exam and 1 person is cheating. A lie detector that is accurate 99% of the time is used to screen the candidates one by one. At some point during the screening the lie detector beeps to signal that the person is lying. What is the probability that the person was actually cheating?
$$P(A|B)=\frac{P(B|A)P(A)}{P(B)}$$
Let A = the person is cheating
Let B = lie detector correct
$$\frac{(0.99).(0.0005)}{(0.9995).(0.01)}$$
$$P(A|B)=0.04952$$
This seems incorrect, I'm not quite sure where I am going wrong.
I think you need to modify your denominator. I believe the correct formulation is:
$P\left(\text{cheated}|\text{detected}\right)=\frac{P\left(\text{detected}|\text{cheated}\right)P\left(\text{cheated}\right)}{P\left(\text{detected}|\text{cheated}\right)P\left(\text{cheated}\right)+P\left(\text{detected}|\text{not cheated}\right)P\left(\text{not cheated}\right)}$
I believe you only computed the second term in the denominator. You need to add the first term (which is the same as the numerator in this case).
I hope this helps.