2 Bayes’ theorem

We again consider the conditional probability statement:

P ( A | B ) = P ( A B ) P ( B ) = P ( A B ) P ( B | A 1 ) P ( A 1 ) + P ( B | A 2 ) P ( A 2 ) + + P ( B | A n ) P ( A n )

in which we have used the theorem of Total Probability to replace P ( B ) . Now

P ( A B ) = P ( B A ) = P ( B | A ) × P ( A )

Substituting this in the expression for P ( A | B ) we immediately obtain the result

P ( A | B ) = P ( B | A ) × P ( A ) P ( B | A 1 ) P ( A 1 ) + P ( B | A 2 ) P ( A 2 ) + + P ( B | A n ) P ( A n )

This is true for any event A and so, replacing A by A i gives the result, known as Bayes’ theorem as

P ( A i | B ) = P ( B | A i ) × P ( A i ) P ( B | A 1 ) P ( A 1 ) + P ( B | A 2 ) P ( A 2 ) + + P ( B | A n ) P ( A n )