From Actuarial Outpost Wiki
From Wikipedia, the free encyclopedia
Bayes' theorem (also known as Bayes' rule or Bayes' law) is a result in probability theory that relates conditional probabilities. If A and B denote two events, P(AB) denotes the conditional probability of A occurring, given that B occurs. The two conditional probabilities P(AB) and P(BA) are generally different. Bayes theorem gives a relation between P(AB) and P(BA).
An important application of Bayes' theorem is that it gives a rule how to update or revise the strengths of evidencebased beliefs in light of new evidence a posteriori.
As a formal theorem, Bayes' theorem is valid in all interpretations of probability. However, it plays a central role in the debate around the foundations of statistics: frequentist and Bayesian interpretations disagree about the kinds of things to which probabilities should be assigned in applications. Whereas frequentists assign probabilities to random events according to their frequencies of occurrence or to subsets of populations as proportions of the whole, Bayesians assign probabilities to propositions that are uncertain. A consequence is that Bayesians have more frequent occasion to use Bayes' theorem. The articles on Bayesian probability and frequentist probability discuss these debates at greater length.
Contents 
Statement of Bayes' theorem
Bayes' theorem relates the conditional and marginal probabilities of stochastic events A and B:
 <math>P(AB) = \frac{P(B  A)\, P(A)}{P(B)}.</math>
Each term in Bayes' theorem has a conventional name:
 P(A) is the prior probability or marginal probability of A. It is "prior" in the sense that it does not take into account any information about B.
 P(AB) is the conditional probability of A, given B. It is also called the posterior probability because it is derived from or depends upon the specified value of B.
 P(BA) is the conditional probability of B given A.
 P(B) is the prior or marginal probability of B, and acts as a normalizing constant.
Bayes' theorem in terms of likelihood
Bayes' theorem can also be interpreted in terms of likelihood:
 <math>P(AB) \propto L(A  B)\, P(A).</math>
Here L(AB) is the likelihood of A given fixed B. The rule is then an immediate consequence of the relationship <math>P(B  A) = L(A  B)</math>. In many contexts the likelihood function L can be multiplied by a constant factor, so that it is proportional to, but does not equal the conditional probability P.
With this terminology, the theorem may be paraphrased as
 <math> \mbox{posterior} = \frac{\mbox{likelihood} \times \mbox{prior}} {\mbox{normalizing constant}} </math>
In words: the posterior probability is proportional to the product of the prior probability and the likelihood.
In addition, the ratio L(AB)/P(B) is sometimes called the standardized likelihood or normalized likelihood, so the theorem may also be paraphrased as
 <math> \mbox{posterior} = {\mbox{normalized likelihood} \times \mbox{prior} }.\, </math>
Derivation from conditional probabilities
To derive the theorem, we start from the definition of conditional probability. The probability of event A given event B is
 <math>P(AB)=\frac{P(A \cap B)}{P(B)}.</math>
Likewise, the probability of event B given event A is
 <math>P(BA) = \frac{P(A \cap B)}{P(A)}. \!</math>
Rearranging and combining these two equations, we find
 <math>P(AB)\, P(B) = P(A \cap B) = P(BA)\, P(A). \!</math>
This lemma is sometimes called the product rule for probabilities. Dividing both sides by P(B), providing that it is nonzero, we obtain Bayes' theorem:
 <math>P(AB) = \frac{P(BA)\,P(A)}{P(B)}. \!</math>
Alternative forms of Bayes' theorem
Bayes' theorem is often embellished by noting that
 <math>P(B) = P(A\cap B) + P(A^C\cap B) = P(BA) P(A) + P(BA^C) P(A^C)\,</math>
where A^{C} is the complementary event of A (often called "not A"). So the theorem can be restated as
 <math>P(AB) = \frac{P(B  A)\, P(A)}{P(BA) P(A) + P(BA^C) P(A^C)}. \!</math>
More generally, where {A_{i}} forms a partition of the event space,
 <math>P(A_iB) = \frac{P(B  A_i)\, P(A_i)}{\sum_j P(BA_j)\,P(A_j)} , \!</math>
for any A_{i} in the partition.
See also the law of total probability.
Bayes' theorem in terms of odds and likelihood ratio
Bayes' theorem can also be written neatly in terms of a likelihood ratio Λ and odds O as
 <math>O(AB)=O(A) \cdot \Lambda (AB) </math>
where <math>O(AB)=\frac{P(AB)}{P(A^CB)} \!</math> are the odds of A given B,
and <math>O(A)=\frac{P(A)}{P(A^C)} \!</math> are the odds of A by itself,
while <math>\Lambda (AB) = \frac{L(AB)}{L(A^CB)} = \frac{P(BA)}{P(BA^C)} \!</math> is the likelihood ratio.
Bayes' theorem for probability densities
There is also a version of Bayes' theorem for continuous distributions. It is somewhat harder to derive, since probability densities, strictly speaking, are not probabilities, so Bayes' theorem has to be established by a limit process; see Papoulis (citation below), Section 7.3 for an elementary derivation. Bayes's theorem for probability densities is formally similar to the theorem for probabilities:
 <math> f(xy) = \frac{f(x,y)}{f(y)} = \frac{f(yx)\,f(x)}{f(y)} \!</math>
and there is an analogous statement of the law of total probability:
 <math> f(xy) = \frac{f(yx)\,f(x)}{\int_{\infty}^{\infty} f(yx)\,f(x)\,dx}.
\!</math>
As in the discrete case, the terms have standard names. f(x, y) is the joint distribution of X and Y, f(xy) is the posterior distribution of X given Y=y, f(yx) = L(xy) is (as a function of x) the likelihood function of X given Y=y, and f(x) and f(y) are the marginal distributions of X and Y respectively, with f(x) being the prior distribution of X.
Here we have indulged in a conventional abuse of notation, using f for each one of these terms, although each one is really a different function; the functions are distinguished by the names of their arguments.
Abstract Bayes' theorem
Given two absolutely continuous probability measures <math>P \sim Q</math> on the probability space <math>(\Omega, \mathcal{F})</math> and a sigmaalgebra <math>\mathcal{G} \subset \mathcal{F}</math>, the abstract Bayes theorem for a <math>\mathcal{F}</math>measurable random variable <math>X</math> becomes
 <math>E_P[X\mathcal{G}] = \frac{E_Q[\frac{dP}{dQ} X \mathcal{G}]}{E_Q[\frac{dP}{dQ}\mathcal{G}]}</math>.
This formulation is used in Kalman filtering to find Zakai equations. It is also used in financial mathematics for change of numeraire techniques.
Extensions of Bayes' theorem
Theorems analogous to Bayes' theorem hold in problems with more than two variables. For example:
 <math> P(AB \cap C) = \frac{P(A) \, P(BA) \, P(CA \cap B)}{P(B) \, P(CB)}\,.</math>
This can be derived in a few steps from Bayes' theorem and the definition of conditional probability:
 <math> P(AB \cap C) = \frac{P(A \cap B \cap C)}{P(B \cap C)} = \frac{P(CA \cap B) \, P(A \cap B)}{P(B) \, P(CB)} = \frac{P(A) \, P(BA) \, P(CA \cap B)}{P(B) \, P(CB)}\,.</math>
Similarly, we have
 <math> P(AB \cap C) = \frac{P(BA \cap C) \, P(AC)}{P(CB)}\,,</math>
which can be regarded as a conditional Bayes' Theorem, and can be derived by as follows:
 <math> P(AB \cap C) = \frac{P(A \cap B \cap C)}{P(B \cap C)} = \frac{P(BA \cap C) \, P(AC) \, P(C)}{P(C) \, P(BC)} = \frac{P(BA \cap C) \, P(AC)}{P(BC)}\,.</math>
A general strategy is to work with a decomposition of the joint probability, and to marginalize (integrate) over the variables that are not of interest. Depending on the form of the decomposition, it may be possible to prove that some integrals must be 1, and thus they fall out of the decomposition; exploiting this property can reduce the computations very substantially. A Bayesian network, for example, specifies a factorization of a joint distribution of several variables in which the conditional probability of any one variable given the remaining ones takes a particularly simple form (see Markov blanket).
Examples
Example #1: Conditional probabilities
Suppose there are two bowls full of cookies. Bowl #1 has 10 chocolate chip cookies and 30 plain cookies, while bowl #2 has 20 of each. Fred picks a bowl at random, and then picks a cookie at random. We may assume there is no reason to believe Fred treats one bowl differently from another, likewise for the cookies. The cookie turns out to be a plain one. How probable is it that Fred picked it out of bowl #1?
Intuitively, this should be greater than half since bowl #1 contains the same number of cookies as bowl #2, yet it has more plain.
We can clarify the situation by rephrasing the question to "what’s the probability that Fred picked bowl #1, given that he has a plain cookie?” The event A is that Fred picked bowl #1, and the event B is that Fred picked a plain cookie. To compute P(AB), we first need to know:
 P(A), or the probability that Fred picked bowl #1 regardless of any other information. Since Fred is treating both bowls equally, it is 0.5.
 P(B), or the probability of getting a plain cookie regardless of any other information. Since there are 80 total cookies, and 50 of them are plain, the probability of selecting a plain cookie is 50/80 = 0.625.
 P(BA), or the probability of getting a plain cookie given Fred picked bowl #1. Since there are 40 cookies in bowl #1 and 30 of them are plain, the probability is 30/40 = 0.75.
Given all this information, we can compute the probability of Fred having selected bowl #1 given that he got a plain cookie by substitution:
 <math>P(AB) = \frac{P(B  A) P(A)}{P(B)} = \frac{0.75 \times 0.5}{0.625} = 0.6</math>
As we expected, it is more than half.
Tables of occurrences and relative frequencies
It is often helpful when calculating conditional probabilities to create a simple table containing the number of occurrences of each outcome, or the relative frequencies of each outcome, for each of the independent variables. The tables below illustrate the use of this method for the cookies.
Number of cookies in each bowl by type of cookie  Relative frequency of cookies in each bowl by type of cookie  



The table on the right is derived from the table on the left by dividing each entry by the total number of cookies under consideration, i.e. dividing each number by 80.
Example #2: Drug testing
Bayes' theorem is useful in evaluating the result of drug tests. Suppose a certain drug test is 99% sensitive and 99% specific, that is, the test will correctly identify a drug user as testing positive 99% of the time, and will correctly identify a nonuser as testing negative 99% of the time. This would seem to be a relatively accurate test, but Bayes' theorem will reveal a potential flaw. Let's assume a corporation decides to test its employees for opium use, and 0.5% of the employees use the drug. We want to know the probability that, given a positive drug test, an employee is actually a drug user. Let "D" be the event of being a drug user and "N" indicate being a nonuser. Let "+" be the event of a positive drug test. We need to know the following:
 P(D), or the probability that the employee is a drug user, regardless of any other information. This is 0.005, since 0.5% of the employees are drug users. This is the prior probability of D.
 P(N), or the probability that the employee is not a drug user. This is Template:Mbox, or 0.995.
 P(+D), or the probability that the test is positive, given that the employee is a drug user. This is 0.99, since the test is 99% accurate.
 P(+N), or the probability that the test is positive, given that the employee is not a drug user. This is 0.01, since the test will produce a false positive for 1% of nonusers.
 P(+), or the probability of a positive test event, regardless of other information. This is 0.0149 or 1.49%, which is found by adding the probability that the test will produce a true positive result in the event of drug use (= 99% x 0.5% = 0.495%) plus the probability that the test will produce a false positive in the event of nondrug use (= 1% x 99.5% = 0.995%). This is the prior probability of +.
Given this information, we can compute the posterior probability P(D+) of an employee who tested positive actually being a drug user:
 <math>\begin{align}P(D+) & = \frac{P(+  D) P(D)}{P(+)} \\
& = \frac{P(+  D) P(D)}{P(+  D) P(D) + P(+  N) P(N)} \\ & = \frac{0.99 \times 0.005}{0.99 \times 0.005 + 0.01 \times 0.995} \\ & = 0.3322\end{align}</math>
Despite the high accuracy of the test, the probability that an employee who tested positive actually did use drugs is only about 33%, so it is actually more likely that the employee is not a drug user. The rarer the condition for which we are testing, the greater the percentage of positive tests that will be false positives. This example illustrates why it is important not to rely on a single test and to do followup tests.
Example #3: Bayesian inference
Applications of Bayes' theorem often assume the philosophy underlying Bayesian probability that uncertainty and degrees of belief can be measured as probabilities. One such example follows. For additional worked out examples, including simpler examples, please see the article on the examples of Bayesian inference.
We describe the marginal probability distribution of a variable A as the prior probability distribution or simply the prior. The conditional distribution of A given the "data" B is the posterior probability distribution or just the posterior.
Suppose we wish to know about the proportion r of voters in a large population who will vote "yes" in a referendum. Let n be the number of voters in a random sample (chosen with replacement, so that we have statistical independence) and let m be the number of voters in that random sample who will vote "yes". Suppose that we observe n = 10 voters and m = 7 say they will vote yes. From Bayes' theorem we can calculate the probability distribution function for r using
 <math> f(r  n=10, m=7) =
\frac {f(m=7  r, n=10) \, f(r)} {\int_0^1 f(m=7r, n=10) \, f(r) \, dr}. \!</math>
From this we see that from the prior probability density function f(r) and the likelihood function L(r) = f(m = 7r, n = 10), we can compute the posterior probability density function f(rn = 10, m = 7).
The prior probability density function f(r) summarizes what we know about the distribution of r in the absence of any observation. We provisionally assume in this case that the prior distribution of r is uniform over the interval [0, 1]. That is, f(r) = 1. If some additional background information is found, we should modify the prior accordingly. However before we have any observations, all outcomes are equally likely.
Under the assumption of random sampling, choosing voters is just like choosing balls from an urn. The likelihood function L(r) = P(m = 7r, n = 10,) for such a problem is just the probability of 7 successes in 10 trials for a binomial distribution.
 <math> P( m=7  r, n=10) = {10 \choose 7} \, r^7 \, (1r)^3. </math>
As with the prior, the likelihood is open to revision  more complex assumptions will yield more complex likelihood functions. Maintaining the current assumptions, we compute the normalizing factor,
 <math> \int_0^1 P( m=7r, n=10) \, f(r) \, dr = \int_0^1 {10 \choose 7} \, r^7 \, (1r)^3 \, 1 \, dr = {10 \choose 7} \, \frac{1}{1320} \!</math>
and the posterior distribution for r is then
 <math> f(r  n=10, m=7) =
\frac{{10 \choose 7} \, r^7 \, (1r)^3 \, 1} {{10 \choose 7} \, \frac{1}{1320}} = 1320 \, r^7 \, (1r)^3 </math>
for r between 0 and 1, inclusive.
One may be interested in the probability that more than half the voters will vote "yes". The prior probability that more than half the voters will vote "yes" is 1/2, by the symmetry of the uniform distribution. In comparison, the posterior probability that more than half the voters will vote "yes", i.e., the conditional probability given the outcome of the opinion poll – that seven of the 10 voters questioned will vote "yes" – is
 <math>1320\int_{1/2}^1 r^7(1r)^3\,dr \approx 0.887, \!</math>
which is about an "89% chance".
Example #4: The Monty Hall problem
We are presented with three doors  red, green, and blue  one of which has a prize. We choose the red door, which is not opened until the presenter performs an action. The presenter who knows what door the prize is behind, and who must open a door, but is not permitted to open the door we have picked or the door with the prize, opens the green door and reveals that there is no prize behind it and subsequently asks if we wish to change our mind about our initial selection of red. What is the probability that the prize is behind the blue and red doors?
Let us call the situation that the prize is behind a given door A_{r}, A_{g}, and A_{b}.
To start with, <math>P(A_r) = P(A_g) = P(A_b) = \frac 1 3</math>, and to make things simpler we shall assume that we have already picked the red door.
Let us call B "the presenter opens the blue door". Without any prior knowledge, we would assign this a probability of 50%
 In the situation where the prize is behind the red door, the host is free to pick between the green or the blue door at random. Thus, <math>P(BA_r) = 1/2</math>
 In the situation where the prize is behind the green door, the host must pick the blue door. Thus, <math>P(BA_g) = 1</math>
 In the situation where the prize is behind the blue door, the host must pick the green door. Thus, <math>P(BA_b) = 0</math>
Thus,
<math> \begin{matrix}
P(A_rB) & = \frac{P(B  A_r) P(A_r)}{P(B)} & = \frac{\frac 1 2 \cdot \frac 1 3}{\frac 1 2} & = \frac 1 3
\\
P(A_gB) & = \frac{P(B  A_g) P(A_g)}{P(B)} & = \frac{1 \cdot \frac 1 3}{\frac 1 2} & = \frac 2 3
\\
P(A_bB) & = \frac{P(B  A_b) P(A_b)}{P(B)} & = \frac{0 \cdot \frac 1 3}{\frac 1 2} & = 0
\end{matrix} </math>
Note how this depends on the value of P(B).
Historical remarks
An investigation by a statistics professor (Stigler 1983) suggests that Bayes' theorem was discovered by Nicholas Saunderson some time before Bayes.
Bayes' theorem is named after the Reverend Thomas Bayes (1702–1761), who studied how to compute a distribution for the parameter of a binomial distribution (to use modern terminology). His friend, Richard Price, edited and presented the work in 1763, after Bayes' death, as An Essay towards solving a Problem in the Doctrine of Chances. PierreSimon Laplace replicated and extended these results in an essay of 1774, apparently unaware of Bayes' work.
One of Bayes' results (Proposition 5) gives a simple description of conditional probability, and shows that it can be expressed independently of the order in which things occur:
 If there be two subsequent events, the probability of the second b/N and the probability of both together P/N, and it being first discovered that the second event has also happened, from hence I guess that the first event has also happened, the probability I am right [i.e., the conditional probability of the first event being true given that the second has also happened] is P/b.
Note that the expression says nothing about the order in which the events occurred; it measures correlation, not causation. His preliminary results, in particular Propositions 3, 4, and 5, imply the result now called Bayes' Theorem (as described above), but it does not appear that Bayes himself emphasized or focused on that result.
Bayes' main result (Proposition 9 in the essay) is the following: assuming a uniform distribution for the prior distribution of the binomial parameter p, the probability that p is between two values a and b is
 <math>
\frac {\int_a^b {n+m \choose m} p^m (1p)^n\,dp}
{\int_0^1 {n+m \choose m} p^m (1p)^n\,dp}
\!</math>
where m is the number of observed successes and n the number of observed failures.
What "Bayesian" about Proposition 9 is that Bayes presented it as a probability for the parameter p. So, one can compute probability for an experimental outcome, but also for the parameter which governs it, and the same algebra is used to make inferences of either kind.
Bayes states his question in a way that might make the idea of assigning a probability distribution to a parameter palatable to a frequentist. He supposes that a billiard ball is thrown at random onto a billiard table, and that the probabilities p and q are the probabilities that subsequent billiard balls will fall above or below the first ball.
References
Versions of the essay
 Thomas Bayes (1763), "An Essay towards solving a Problem in the Doctrine of Chances. By the late Rev. Mr. Bayes, F. R. S. communicated by Mr. Price, in a letter to John Canton, A. M. F. R. S.", Philosophical Transactions, Giving Some Account of the Present Undertakings, Studies and Labours of the Ingenious in Many Considerable Parts of the World 53:370–418.
 Thomas Bayes (1763/1958) "Studies in the History of Probability and Statistics: IX. Thomas Bayes' Essay Towards Solving a Problem in the Doctrine of Chances", Biometrika 45:296–315. (Bayes' essay in modernized notation)
 Thomas Bayes "An essay towards solving a Problem in the Doctrine of Chances". (Bayes' essay in the original notation)
Commentaries
 G. A. Barnard (1958) "Studies in the History of Probability and Statistics: IX. Thomas Bayes' Essay Towards Solving a Problem in the Doctrine of Chances", Biometrika 45:293–295. (biographical remarks)
 Daniel Covarrubias. "An Essay Towards Solving a Problem in the Doctrine of Chances". (an outline and exposition of Bayes' essay)
 Stephen M. Stigler (1982). "Thomas Bayes' Bayesian Inference," Journal of the Royal Statistical Society, Series A, 145:250–258. (Stigler argues for a revised interpretation of the essay; recommended)
 Isaac Todhunter (1865). A History of the Mathematical Theory of Probability from the time of Pascal to that of Laplace, Macmillan. Reprinted 1949, 1956 by Chelsea and 2001 by Thoemmes.
Additional material
 PierreSimon Laplace (1774), "Mémoire sur la Probabilité des Causes par les Événements", Savants Étranges 6:621–656; also Œuvres 8:27–65.
 PierreSimon Laplace (1774/1986), "Memoir on the Probability of the Causes of Events", Statistical Science 1(3):364–378.
 Stephen M. Stigler (1986), "Laplace's 1774 memoir on inverse probability", Statistical Science 1(3):359–378.
 Stephen M. Stigler (1983), "Who Discovered Bayes' Theorem?" The American Statistician 37(4):290–296.
 Jeff Miller, et al., Earliest Known Uses of Some of the Words of Mathematics (B). (very informative; recommended)
 Athanasios Papoulis (1984), Probability, Random Variables, and Stochastic Processes, second edition. New York: McGrawHill.
 James Joyce (2003), "Bayes' Theorem", Stanford Encyclopedia of Philosophy.
 The online textbook: Information Theory, Inference, and Learning Algorithms, by David J. C. MacKay provides an up to date overview of the use of Bayes' theorem in information theory and machine learning.
 Stanford Encyclopedia of Philosophy: Bayes' Theorem provides a comprehensive introduction to Bayes' theorem.
 Stanford Encyclopedia of Philosophy: Inductive Logic provides a comprehensive Bayesian treatment of Inductive Logic and Confirmation Theory.
 Template:MathWorld
 Template:PlanetMath
 Eliezer S. Yudkowsky (2003), "An Intuitive Explanation of Bayesian Reasoning"
 A tutorial on probability and Bayes’ theorem devised for Oxford University psychology students
 Confirmation Theory An extensive presentation of Bayesian Confirmation Theory