The posterior distribution is the probability distribution over unknown quantities, such as model parameters or latent variables, after observed data have been taken into account. In Bayesian inference it is the central result: it combines the prior distribution, which encodes beliefs before the data, with the likelihood, which measures how well each parameter value explains the data.
Within probabilistic models used in artificial intelligence, the posterior is what a model actually learns. Point estimates, credible intervals, predictions for new data and decisions under uncertainty are all derived from it, which is why computing or approximating the posterior is the main computational challenge of Bayesian machine learning.
How Bayes’ rule produces the posterior distribution
The posterior follows directly from Bayes’ rule: p(θ | D) = p(D | θ) p(θ) / p(D). Here θ denotes the parameters, D the observed data, p(θ) the prior, p(D | θ) the likelihood and p(D) the marginal likelihood, also called the evidence. The posterior is therefore proportional to likelihood times prior, and the evidence only rescales it so that it integrates to one.
Each component plays a distinct role, and the table below summarizes what each one contributes and how it is typically obtained.
| Component | Notation | Role in the posterior |
|---|---|---|
| Prior | p(θ) | Beliefs about parameters before seeing data |
| Likelihood | p(D | θ) | Fit of each parameter value to the data |
| Marginal likelihood | p(D) | Normalizing constant, used for model comparison |
| Posterior | p(θ | D) | Updated beliefs after observing the data |
Updating is sequential and consistent: today’s posterior can serve as tomorrow’s prior when new observations arrive. As the amount of data grows, the likelihood usually dominates, and under regularity conditions the posterior concentrates around the true parameter, a result known as the Bernstein-von Mises theorem.
Summarizing and using the posterior
A full posterior is a whole distribution, so practitioners extract summaries suited to the decision at hand. The choice of summary matters, because the mean, median and mode coincide only for symmetric, unimodal posteriors.
| Summary | Definition | Typical use |
|---|---|---|
| Posterior mean | Expected value under the posterior | Minimizes squared-error loss |
| Posterior median | Value splitting mass into halves | Robust to skewed posteriors |
| Posterior mode (MAP) | Most probable parameter value | Fast point estimate, regularized fitting |
| Credible interval | Range holding, for example, 95% of mass | Reporting parameter uncertainty |
| Posterior predictive | Average of predictions over the posterior | Forecasting new observations |
The posterior predictive distribution is often the most valuable output in machine learning. Instead of predicting with a single best parameter, it averages predictions across all plausible parameters, which yields better calibrated uncertainty and reduces overconfidence on unfamiliar inputs.
Computing the posterior exactly and approximately
The posterior has a closed form only in special cases, mainly when the prior is a conjugate prior for the likelihood. A Beta prior with a binomial likelihood, for example, yields a Beta posterior whose parameters simply add observed successes and failures. In most realistic models the evidence p(D) is an intractable high-dimensional integral, so the posterior must be approximated.
The main approximation families trade accuracy against speed, and the table below compares them.
| Method | Principle | Strength | Weakness |
|---|---|---|---|
| Conjugate analysis | Closed-form update | Exact and instant | Restricted model choice |
| Markov chain Monte Carlo | Samples from the posterior | Asymptotically exact | Slow, needs convergence checks |
| Variational inference | Optimizes a simpler distribution | Scales to large data | Often underestimates variance |
| Laplace approximation | Gaussian at the mode | Cheap given the MAP | Poor for skewed posteriors |
| Expectation propagation | Local moment matching | Good marginals | May fail to converge |
Modern samplers such as Hamiltonian Monte Carlo and the No-U-Turn Sampler use gradient information to explore posteriors with thousands of parameters. Variational methods minimize the Kullback-Leibler divergence to the posterior by maximizing the evidence lower bound, which makes them practical for Bayesian neural networks and large latent variable models.
Posterior distribution compared with related estimates
The posterior differs from frequentist and point-estimate approaches in what it treats as uncertain. Maximum likelihood estimation returns one parameter value and expresses uncertainty through hypothetical repeated sampling, whereas the posterior assigns probability directly to parameter values.
| Concept | Output | Uses prior | Captures parameter uncertainty |
|---|---|---|---|
| Posterior distribution | Full distribution | Yes | Yes, directly |
| Maximum likelihood estimate | Single value | No | Only via sampling theory |
| MAP estimate | Single value | Yes | No |
| Prior distribution | Full distribution | Is the prior | Before data only |
The MAP estimate is the mode of the posterior, and with a Gaussian prior it is equivalent to L2-regularized maximum likelihood. This link explains why regularization in deep learning can be read as an implicit prior. However, a single mode discards the spread and shape of the posterior, so two models with identical MAP estimates can carry very different uncertainty.
In hierarchical models, the posterior also covers hyperparameters and group-level effects. Partial pooling then lets groups with little data borrow strength from the others, which is a practical advantage over fitting each group separately.
Pitfalls when working with posteriors
The posterior is only as trustworthy as the model and prior behind it. A misspecified likelihood produces a confident but wrong posterior, and with small datasets an unjustified informative prior can dominate the result. Prior sensitivity analysis and posterior predictive checks are standard safeguards.
- Multimodal posteriors can trap samplers in one mode, so several chains and diagnostics such as R-hat are essential.
- Variational approximations often look precise yet understate uncertainty, which matters in safety-critical decisions.
- A 95% credible interval states probability about the parameter given the data, which differs from a confidence interval.
- Improper priors can yield an improper posterior that cannot be normalized at all.
In simple terms
A posterior distribution is what you believe after seeing the evidence. You start with a guess about something unknown. Then you collect data. The data shift your guess toward the values that explain what you saw.
Think of a doctor. Before any test, the doctor has a rough idea of what is wrong. A test result then makes some causes more likely and others less likely. The updated picture is the posterior. It also shows how sure you can be, not just one best answer.
A practical example
An online retailer tests a new checkout page. Before the test, analysts set a Beta(2, 38) prior on the conversion rate, reflecting past rates near 5%. After 1,000 visits with 62 purchases, the conjugate update gives a Beta(64, 976) posterior, centered near 6.2%.
The analysts compare this with the posterior for the old page and compute the probability that the new page converts better, which comes out at about 93%. They also draw from both posteriors to estimate expected revenue per visitor.
Because the posterior quantifies uncertainty directly, the team decides to extend the test for one more week rather than switch immediately. The extra data narrow the credible interval enough to justify the rollout with confidence.