information:classification, information:filtering, stylistic:style_transfer, information:highlighting
Bayes' theorem

Bayes' theorem is used in Bayesian methods to update probabilities, which are degrees of belief, after obtaining new data. Given two events A {\displaystyle A} and B {\displaystyle B}, the conditional probability of A {\displaystyle A} given that B {\displaystyle B} is true is expressed as follows:

P (A ∣ B) = P (B ∣ A) P (A) P (B) {\displaystyle P(A\mid B)={\frac {P(B\mid A)P(A)}{P(B)}}}

where P (B) ≠ 0 {\displaystyle P(B)\neq 0}. Although Bayes' theorem is a fundamental result of probability theory, it has a specific interpretation in Bayesian statistics. In the above equation, A {\displaystyle A} usually represents a proposition (such as the statement that a coin lands on heads fifty percent of the time) and B {\displaystyle B} represents the evidence, or new data that is to be taken into account (such as the result of a series of coin flips). P (A) {\displaystyle P(A)} is the prior probability of A {\displaystyle A} which expresses one's beliefs about A {\displaystyle A} before evidence is taken into account. The prior probability may also quantify prior knowledge or information about A {\displaystyle A}. P (B ∣ A) {\displaystyle P(B\mid A)} is the likelihood function, which can be interpreted as the probability of the evidence B {\displaystyle B} given that A {\displaystyle A} is true. The likelihood quantifies the extent to which the evidence B {\displaystyle B} supports the proposition A {\displaystyle A}. P (A ∣ B) {\displaystyle P(A\mid B)} is the posterior probability, the probability of the proposition A {\displaystyle A} after taking the evidence B {\displaystyle B} into account. Essentially, Bayes' theorem updates one's prior beliefs P (A) {\displaystyle P(A)} after considering the new evidence B {\displaystyle B}.

The probability of the evidence P (B) {\displaystyle P(B)} can be calculated using the law of total probability. If { A 1, A 2, …, A n } {\displaystyle \{A_{1},A_{2},\dots,A_{n}\}} is a partition of the sample space, which is the set of all outcomes of an experiment, then,

P (B) = P (B ∣ A 1) P (A 1) + P (B ∣ A 2) P (A 2) + ⋯ + P (B ∣ A n) P (A n) = ∑ i P (B ∣ A i) P (A i) {\displaystyle P(B)=P(B\mid A_{1})P(A_{1})+P(B\mid A_{2})P(A_{2})+\dots +P(B\mid A_{n})P(A_{n})=\sum _{i}P(B\mid A_{i})P(A_{i})}

When there are an infinite number of outcomes, it is necessary to integrate over all outcomes to calculate P (B) {\displaystyle P(B)} using the law of total probability. Often, P (B) {\displaystyle P(B)} is difficult to calculate as the calculation would involve sums or integrals that would be time-consuming to evaluate, so often only the product of the prior and likelihood is considered, since the evidence does not change in the same analysis. The posterior is proportional to this product:

P (A ∣ B) ∝ P (B ∣ A) P (A) {\displaystyle P(A\mid B)\propto P(B\mid A)P(A)}

The maximum a posteriori, which is the mode of the posterior and is often computed in Bayesian statistics using mathematical optimization methods, remains the same. The posterior can be approximated even without computing the exact value of P (B) {\displaystyle P(B)} with methods such as Markov chain Monte Carlo or variational Bayesian methods.