TL;DR
The posterior distribution is what you believe about an unknown quantity after you have seen some data. You start from a prior, which is your belief before the data. You then multiply it by how well each possible value explains the data, the likelihood, and rescale so the beliefs add up to one.
Where you'll see it: in any Bayesian estimate, such as the probability that a coin is biased after a few flips, the updated spam score for an email, or the error bars reported alongside a fitted model.
Intuition
Start from a question you already ask
Suppose a friend hands you a coin and says it might be fair or might be loaded toward heads. Before flipping, you would say both are equally likely. Now you flip it and get heads. Did that change your mind? A little, toward the loaded coin, because a loaded coin makes heads more likely. The posterior is the precise version of this change of mind: a new set of beliefs, one for each possible coin, that combines what you thought before with what the flip showed.
Beliefs as a set of weights
Think of each possible value of the unknown quantity as a candidate, with a weight. The prior gives each candidate its starting weight. The data then reweights the candidates: a candidate that makes the data likely gains weight, and a candidate that makes the data surprising loses weight. Finally, the weights are scaled so they sum to one. The result is still a list of candidates with weights, which is the posterior.
flowchart LR A[Prior: belief before data] --> C[Multiply weight by likelihood] B[Likelihood: how well each value explains the data] --> C C --> D[Rescale so weights sum to 1] D --> E[Posterior: belief after data] E -.->|becomes the prior for the next batch of data| A
The last arrow is important. The posterior from one batch of data is a perfectly good prior for the next batch. This is how Bayesian learning accumulates evidence without starting over.
The math
Definition
Let be an unknown quantity and the observed data. The posterior distribution of given is
where is the prior, is the likelihood, and is the evidence.
Here stands for any candidate value of the unknown, such as a coin's heads probability. The symbol is the prior: how plausible each was before the data. The symbol is a conditional probability and serves as the likelihood: how probable the observed data would be if were the true value. The left-hand side is the posterior, the plausibility of each after seeing . This is Bayes' rule applied to a quantity we want to learn.
The evidence is a normaliser
The denominator does not depend on . It is the total weight of all candidates together, and it makes the posterior sum (or integrate) to one. For a discrete set of candidates, the law of total probability gives
Because is only a scaling factor, the shortcut used in practice is
read "the posterior is proportional to likelihood times prior". Compute the product for every candidate, then divide by the sum of the products.
Continuous quantities
When can take any value, the sum becomes an integral and the posterior is a density. The same rule holds: multiply prior density by likelihood, then divide by the integral of that product over all . Most of the difficulty in Bayesian statistics is in computing that integral, which is why approximate methods exist. The examples below use a few candidate values so every number can be checked by hand.
Posterior and maximum likelihood
The maximum likelihood estimate picks the with the largest likelihood and ignores the prior. The posterior mode (the most probable after seeing the data) is the value that maximises likelihood times prior. The two agree when the prior is flat (every candidate starts with the same weight). The posterior gives more than a single best value: it gives a weight for every candidate, so you can see how uncertain the answer is.
Worked examples
Two candidate coins: a fair coin with heads probability , or a loaded coin with heads probability . Before flipping, you judge them equally likely, so . You flip once and get heads.
- Likelihoods of heads: and .
- Multiply by the prior: fair gives , and loaded gives .
- Add the products to get the evidence: .
- Divide each product by the evidence. Posterior for fair: . Posterior for loaded: .
- Check: .
Interpretation: one head moved belief toward the loaded coin, from 50% to about 62%. It did not settle the question, because one flip is weak evidence. Notice that the posterior is not the likelihood: the loaded coin has the higher likelihood, but the posterior weighs it against the prior too.
Suppose the heads probability is one of three values, , or , with a uniform prior of each. You flip five times and see four heads and one tail. The likelihood of a specific sequence with heads and tails is . Here and , so the likelihood is . The count of orderings is the same for every , so it cancels and we can ignore it.
- For : .
- For : .
- For : .
- Multiply each by the prior , which is the same factor for all three, so we can skip it and simply sum the unnormalised weights: .
- Divide each weight by :
- :
- :
- :
- Check: .
Interpretation: the data favour the high bias, and the posterior puts about 72% on . The candidate is almost ruled out, since four heads in five flips would be very unlikely from it. Had the prior been different, the answer would move, which is the point of stating the prior openly.
A mail filter has a prior: 40% of incoming mail is spam. Among spam, the word "free" appears in 30% of messages. Among ordinary mail, it appears in 2%. An email arrives containing "free". What is the posterior probability that it is spam?
- Prior: and , where ham means ordinary mail.
- Likelihood of the data under each hypothesis: and .
- Multiply: spam gives , and ham gives .
- Evidence: .
- Posterior for spam: .
- Posterior for ham: . The two add to 1.
Interpretation: the word raises the spam probability from 40% to about 91%. Two facts drive this. The word is much more common in spam (a likelihood ratio of ), and the prior is not extreme. A filter that also sees other words would apply the same rule again, with this posterior as the new prior.
Tradeoffs and failure modes
The posterior is only as good as the prior and the likelihood behind it. The table lists common issues.
| Situation | What goes wrong | Better choice |
|---|---|---|
| The prior is strong and the data are few | The posterior mostly repeats the prior | Collect more data, or state the prior's influence openly |
| The prior is badly chosen | A wrong belief can dominate the result | Check sensitivity: rerun with several reasonable priors |
| The model of the data is wrong | The likelihood is misleading, so the posterior is confidently wrong | Check the model against held-out data |
| The parameter space is large | The evidence integral cannot be computed exactly | Use approximations, such as sampling or variational methods |
A practical point: a posterior is a full distribution, so report it, not just its peak. A narrow posterior and a wide one can share the same most-probable value.
History
Thomas Bayes wrote down the rule that bears his name in an essay published after his death in 1763, in the context of inferring causes from observed effects. Pierre-Simon Laplace developed the general method of updating beliefs with data in the late 1700s and early 1800s and popularised it widely. The word "posterior" itself comes from the Latin for "later": it is the belief held after the data arrive. For much of the twentieth century, frequentist methods dominated statistics, and Bayesian methods were regarded as subjective. Computing power changed that. Sampling methods made it practical to compute posteriors for complex models, and posteriors are now routine in fields from genetics to machine learning.
Recap
Bayes' rule says the posterior is proportional to likelihood times prior. The prior encodes what was believed before the data, and the likelihood measures how well each candidate explains the data. Dividing by the evidence makes the weights add to one. The posterior is the object that Bayesian estimates, uncertainty ranges and sequential updating are all built from.
Check yourself
QuestionRecall: what are the three ingredients in Bayes' rule for a posterior, and which one is the normaliser?Show answer
The three ingredients are the prior , the likelihood and the evidence . The evidence is the normaliser: it does not depend on the candidate , and it makes the posterior weights sum (or integrate) to one.
QuestionComputation: a coin is either fair (heads probability ) or loaded toward tails (heads probability ), each with prior probability . You flip once and get tails. What is the posterior probability that the coin is loaded?Show answer
The likelihood of tails is for the fair coin and for the loaded coin. Multiply by the prior: fair gives and loaded gives . The evidence is . The posterior probability of loaded is .
QuestionWhy: why is the posterior mode not always the same as the maximum likelihood estimate?Show answer
The posterior weights each candidate by likelihood times prior, while maximum likelihood uses the likelihood alone. When the prior is flat, the two rank candidates identically and the peaks coincide. When the prior favours some candidates, it shifts the posterior peak toward them, so the two estimates can differ.
QuestionApplied: a spam filter sees a second word, a word that is three times as common in spam as in ordinary mail. How should the posterior for the email be updated?Show answer
Use the posterior from the first word as the new prior, then multiply by the likelihood of the second word under each hypothesis, and normalise again. The second word's effect is the ratio of its likelihoods under spam and ordinary mail, which is 3 in this case, so the odds of spam are multiplied by 3. This assumes the two words are independent given the class, which is a modelling choice that should be checked.