# Bayesian inference

**Bayesian inference**is statistical inference in which probabilities are interpreted not as frequencies or proportions or the like, but rather as degrees of belief. The name comes from the frequent use of the Bayes' theorem in this discipline.

Bayes' theorem is named after the Reverend Thomas Bayes. However, it is not clear that Bayes would endorse the very broad interpretation of probability now called "Bayesian". This topic is treated at greater length in the article Thomas Bayes.

## Evidence and the scientific method

Bayesian statisticians claim that methods of Bayesian inference are a formalisation of the scientific method involving collecting evidence which points towards or away from a given hypothesis. There can never be certainty, but as evidence accumulates, the degree of belief in a hypothesis changes; with enough evidence it will often become very high (almost 1) or very low (near 0).Bayes theorem provides a method for adjusting degrees of belief in the light of new information. Bayes' theorem is

*ab initio*or induced from some preceding set of observations, but before the new observation or evidence .

- The term is called the
*prior probability*of . - The term is the
*conditional probability*of seeing the observation given that the hypothesis is true; as a function of given , it is called the*likelihood function*. - The term is called the
*marginal probability*of ; it is a*normalizing constant*and can be calculated as the sum of all mutually exclusive hypotheses . - The term is called the
*posterior probability*of given .

The keys to making the inference work is the assigning of the prior probabilities given to the hypothesis and possible alternatives, and the calculation of the conditional probabilities of the observation under different hypotheses.

Some Bayesian statisticians believe that if the prior probabilities can be given some *objective* value, then the theorem can be used to provide an objective measure of the probability of the hypothesis. But to others there is no clear way in which to assign objective probabilities. Indeed, doing so appears to require one to assign probabilities to all possible hypotheses.

Alternately, and more often, the probabilities can be taken as a measure of the *subjective degree of belief* on the part of the participant, and to restrict the potential hypotheses to a constrained set within a model. The theorem then provides a rational measure of the degree to which some observation should alter the subject's belief in the hypothesis. But in this case the resulting posterior probability remains subjective. So the theorem can be used to rationally justify belief in some hypothesis, but at the expense of rejecting objectivism.

In practice, if two individuals do not completely reject each other's initial hypotheses and have the same conditional probabilities then, even with very different assignments of prior probabilities, sufficient observations are likely to bring their posterior probabilites closer together.

In many cases, the impact of observations as evidence can be summarised in a likelihood ratio, as expressed in the law of likelihood. This can be combined with the prior probability to reflect the original degree of belief and any earlier evidence already taken into account. For example, if we have the likelihood ratio

- if
- and
- then ,

Before a decision is made, the loss function also needs to be considered to reflect the consequences of making an erroneous decision.

## Simple examples of Bayesian inference

### From which bowl is the cookie?

Before observing the cookie, the probability that Fred chose bowl #1 is the prior probability,*P*(

*H*

_{1}), which is 0.5. After observing the cookie, we revise the probability to

*P*(

*H*

_{1}|

*D*), which is 0.6.

### False positives in a medical test

False positives are a problem in any kind of test: no test is perfect, and sometimes the test will incorrectly report a positive result. For example, if a test for a particular disease is performed on a patient, then there is a chance (usually small) that the test will return a positive result even if the patient does not have the disease. The problem lies, however, not just in the chance of a false positive prior to testing, but determining the chance that a positive result is in fact a false positive. As we will demonstrate, using Bayes' theorem, if a condition is rare, then the majority of positive results may be false positives, even if the test for that condition is (otherwise) reasonably accurate.

Suppose that a test for a particular disease has a very high success rate:

- if a tested patient has the disease, the test accurately reports this, a 'positive', 99% of the time (or, with probability 0.99), and
- if a tested patient does not have the disease, the test accurately reports that, a 'negative', 95% of the time (
*i.e.*with probability 0.95).

*i.e.*with probability 0.001). We now have all the information required to use Bayes' theorem to calculate the probability that, given the test was positive, that it is a false positive.

Let *A* be the event that the patient has the disease, and *B* be the event that the test returns a positive result. Then, using the second alternative form of Bayes' theorem (above), the probability of a *true* positive is

Despite the apparent high accuracy of the test, the incidence of the disease is so low (one in a thousand) that the vast majority of patients who test positive (98 in a hundred) do not have the disease. (Nonetheless, this is 20 times the proportion before we knew the outcome of the test! The test is not useless, and re-testing may improve the reliability of the result.) In particular, a test must be very reliable in reporting a negative result when the patient does not have the disease, if it is to avoid the problem of false positives. In mathematical terms, this would ensure that the second term in the denominator of the above calculation is small, relative to the first term. For example, if the test reported a negative result in patients without the disease with probability 0.999, then using this value in the calculation yields a probability of a false positive of roughly 0.5.

In this example, Bayes' theorem helps show that the accuracy of tests for rare conditions must be very high in order to produce reliable results from a single test, due to the possibility of false positives. (The probability of a 'false negative' could also be calculated using Bayes' theorem, to completely characterise the possible errors in the test results.)

### In the courtroom

Bayesian inference can be used to coherently assess additional evidence of guilt in a court setting.

- Let G be the event that the defendent is guilty.
- Let E be the event that the defendent's DNA matches DNA found at the crime scene.
- Let p(E | G) be the probability of seeing event E assuming that the defendent is guilty. (Usually this would be taken to be unity.)
- Let p(G | E) be the probability that the defendent is guilty assuming the DNA match event E
- Let p(G) be the probability that the defendent is guilty, based on the evidence other than the DNA match.

- p(G | E) = p(G) p(E | G) / p(E)

^{-6}.

The event E can occur in two ways. Either the defendent is guilty (with prior probability 0.3) and thus his DNA is present with probability 1, or he is innocent (with prior probability 0.7) and he is unlucky enough to be one of the 1 in a million matching people.

Thus the juror could coherently revise his opinion to take into account the DNA evidence as follows:

- p(G | E) = (0.3 × 1.0) /(0.3 × 1.0 + 0.7 × 10
^{-6}) = 0.99999766667.

### Search theory

In May 1968 the US nuclear submarine Scorpion (SSN 589) failed to arrive as expected at her home port of Norfolk, Virginia. The US Navy was convinced that the vessel had been lost off the Eastern seabord but an extensive search failed to discover the wreck. The US Navy's deep water expert, John Craven, believed that it was elsewhere and he organised a search south west of the Azores based on a controversial approximate triangulation by hydrophones. He was allocated only a single ship, the USNS Mizar, and he took advice from a firm of consultant mathematicians in order to maximise his resources. A Bayesian search methodology was adopted. Experienced submarine commanders were interviewed to construct hypotheses about what could have caused the loss of the Scorpion. The sea area was divided up into grid squares and a probability assigned to each square, under each of the hypotheses, to give a number of probability grids, one for each hypothesis. These were then added together to produce an overall probability grid. The probability attached to each square was then the probability that the wreck was in that square. A second grid was constructed with probabilities that represented the probability of successfully finding the wreck if that square were to be searched and the wreck were to be actually there. This was a known function of water depth. The result of combining this grid with the previous grid is a grid which gives the probability of finding the wreck in each grid square of the sea if it were to be searched. This sea grid was systematically searched in a manner which started with the high probability regions first and worked down to the low probability regions last. Each time a grid square was searched and found to be empty its probability was reassessed using Bayes' theorem. This then forced the probabilities of all the other grid squares to be reassessed (upwards), also by Bayes' theorem. The use of this approach was a major computational challenge for the time but it was eventually successful and the Scorpion was found in October of that year. Suppose a grid square has a probability p of containing the wreck and that the probability of successfully detecting the wreck if it is there is q. If the square is searched and no wreck is found then, by Bayes, the revised probability of the wreck being in the square is given by

## More mathematical examples

### Naive Bayes classifier

*See:* naive Bayesian classification.

### Posterior distribution of the binomial parameter

For a given value of *a*,
the probability of *m* successes in *m*+*n* trials is

*m*and

*n*are fixed, and

*a*is unknown, this is a likelihood function for

*a*. From the continuous form of the law of total probability we have

*p*(

*a*), the integral can be solved and the posterior takes a convenient form. In particular, if

*p*(

*a*) is a beta distribution with parameters

*m*

_{0}and

*n*

_{0}, then the posterior is also a beta distribution with parameters

*m*+

*m*

_{0}and

*n*+

*n*

_{0}.

A *conjugate prior* is a prior distribution, such as the beta distribution in the above example, which has the property that the posterior is the same type of distribution.

What is "Bayesian" about Proposition 9 is that Bayes presented it as a probability for the parameter *a*. That is, not only can one compute probabilities for experimental outcomes, but also for the parameter which governs them, and the same algebra is used to make inferences of either kind. Interestingly, Bayes actually 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. By making the binomial parameter *a* depend on a random event, he cleverly escapes a philosophical quagmire that was an issue he most likely was not even aware of.

### Computer applications

Bayesian inference has applications in artificial intelligence and expert systems. Bayesian inference techniques have been a fundamental part of computerized pattern recognition techniques since the late 1950s.There is growing interest in using Bayesian inference to filter spam. For example: Bogofilter, SpamAssassin and Mozilla.

In some applications fuzzy logic is an alternative to Bayesian inference. Fuzzy logic and Bayesian inference, however, are mathematically and semantically not compatible: You cannot, in general, understand the *degree of truth* in fuzzy logic as probability and vice versa.

## See also:

- Bayesian model comparison
- Bayesian probability
- Occam's Razor
- Prosecutor's fallacy
- Minimum description length
- Gaussian process regression

## External links

- On-line textbook: Information Theory, Inference, and Learning Algorithms, by David MacKay, has many chapters on Bayesian methods, including introductory examples; compelling arguments in favour of Bayesian methods; state-of-the-art Monte Carlo methods, message-passing methods, and variational methods; and examples illustrating the intimate connections between Bayesian inference and data compression.
- Naive Bayesian learning paper
- A Tutorial on Learning With Bayesian Networks