Bayes' rule: Functional form

Written by Eliezer Yudkowsky, So8res, et al. last updated

Bayes' rule generalizes to continuous functions, and states, "The posterior probability density is proportional to the likelihood function times the prior probability density."

Example

Suppose we have a biased coin with an unknown bias between 0 and 1 of coming up heads on each individual coinflip. Since the bias is a continuous variable, we express our beliefs about the coin's bias using a probability density function where is the probability that is in the interval for small. (Specifically, the probability that is in the interval is )

By hypothesis, we start out completely ignorant of the bias meaning that all initial values for are equally likely. Thus, for all values of which means that (e.g., the chance of being found in the interval from 0.72 to 0.76 is 0.04).

plot y = 1 + x * 0, x = 0 to 1

We then flip the coin, and observe it to come up tails. This is our first piece of evidence. The likelihood of observation given bias is a continuous function of , equal to 0.4 if 0.67 if and so on (because is the probability of heads and the observation was tails).

Graphing the likelihood function as it takes in the fixed evidence and ranges over variable we obtain the straightforward graph

plot y = 1 - x, x = 0 to 1

If we multiply the likelihood function by the prior probability function as it ranges over , we obtain a relative probability function on the posterior, which gives us the same graph again:

plot y = 1 - x, x = 0 to 1

But this can't be our posterior probability function because it doesn't integrate to 1. (The area under a triangle is half the base times the height.) Normalizing this relative probability function will give us the posterior probability function:

plot y = 2(1 - x), x = 0 to 1

The shapes are the same, and only the y-axis labels have changed to reflect the different heights of the pre-normalized and normalized function

Regraph these graphs with actual height changes

Suppose we now flip the coin another two times, and it comes up heads then tails. We'll denote this piece of evidence Although these two coin tosses pull our beliefs about in opposite directions, they don't cancel out — far from it! In fact, one value of ("the coin is always tails") is completely eliminated by this evidence, and many extreme values of ("almost always heads" and "almost always tails") are hit badly. That is, while the heads and the coins tails pull our beliefs in opposite directions, they don't pull with the same strength on all possible values of

We multiply the old belief

plot y = 2(1 - x), x = 0 to 1

by the additional pieces of evidence

and

and obtain the posterior relative density

plot y = 2(1 - x)x(1 - x), x = 0 to 1

which is proportional to the normalized posterior probability

plot y = 12(1 - x)x(1 - x), x = 0 to 1

Writing out the whole operation from scratch:

Note that it's okay for a posterior probability density to be greater than 1, so long as the total probability mass isn't greater than 1. If there's probability density 1.2 over an interval of 0.1, that's only a probability of 0.12 for the true value to be found in that interval.

Thus, intuitively, Bayes' rule "just works" when calculating the posterior probability density from the prior probability density function and the (continuous) likelihood ratio function. A proof is beyond the scope of this guide; refer to Proof of Bayes' rule in the continuous case.

Parents: