Bayes’ theorem tells you how to revise a probability after observing new evidence. Thomas Bayes’s work was published after his death; Laplace later developed related results. Applications range from diagnosis and document classification to the recursive state estimation used in Kalman filtering.
1. The law of total probability
Split an event \(A\) into the part that occurs with \(B\) and the part that occurs with its complement. If both conditioning events have positive probability:
\[P(A)=P(A\mid B)P(B)+P(A\mid B^c)P(B^c).\]For any mutually exclusive, exhaustive partition \(B_i\), sum the conditional probabilities weighted by the prior probability of each case:
\[P(A)=\sum_i P(A\mid B_i)P(B_i).\]If the conditioning variable \(X\) is continuous with density \(f_X\), replace the weighted sum with an integral:
\[P(A)=\int P(A\mid X=x)f_X(x)\,\mathrm dx.\]2. Bayes’ theorem
Write the joint probability in either order: \(P(A\cap B)=P(A\mid B)P(B)=P(B\mid A)P(A)\). For \(P(A)>0\) and \(P(B)>0\), this yields:
\[P(B\mid A)=\frac{P(A\mid B)P(B)}{P(A)}.\]For a partition, substitute the law of total probability into the denominator:
\[P(B_j\mid A)=\frac{P(A\mid B_j)P(B_j)}{\sum_i P(A\mid B_i)P(B_i)}.\]For a continuous variable, observing \(A\) updates its density, not the probability of a single point:
\[f_{X\mid A}(x)=\frac{P(A\mid X=x)f_X(x)}{\int P(A\mid X=u)f_X(u)\,\mathrm du}.\]
