Mathematically, Bayes' theorem gives the relationship between the probabilities of A and B, P(A) and P(B), and the conditional probabilities of A given B and B given A, P(A|B) and P(B|A).
P(A|B) = {P(B|A)*P(A)}/{P(B)}
DERIVATION
We can do it from set theory applied to conditional probabilities.
P(A given B) = P(A and B)/P(B)
Likewise, P(B given A) = P(A and B)/P(A)
Rearrange to get the common term as follows:
P(A and B) = P(A given B).P(B) = P(B given A).P(A)
Divide the middle and right hand terms by P(B) on condition that it is not zero:
P(A given B) = P(B given A).P(A)/P(B)
That is a basic statement of Bayes' Theorem.
Statistics Help - http://math.tutorvista.com/statistics.html