Posterior distribution

Also known as: posterior probability

On this page 7

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.

ComponentNotationRole in the posterior
Priorp(θ)Beliefs about parameters before seeing data
Likelihoodp(D | θ)Fit of each parameter value to the data
Marginal likelihoodp(D)Normalizing constant, used for model comparison
Posteriorp(θ | D)Updated beliefs after observing the data
Components of Bayes’ rule

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.

SummaryDefinitionTypical use
Posterior meanExpected value under the posteriorMinimizes squared-error loss
Posterior medianValue splitting mass into halvesRobust to skewed posteriors
Posterior mode (MAP)Most probable parameter valueFast point estimate, regularized fitting
Credible intervalRange holding, for example, 95% of massReporting parameter uncertainty
Posterior predictiveAverage of predictions over the posteriorForecasting new observations
Common posterior summaries

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.

MethodPrincipleStrengthWeakness
Conjugate analysisClosed-form updateExact and instantRestricted model choice
Markov chain Monte CarloSamples from the posteriorAsymptotically exactSlow, needs convergence checks
Variational inferenceOptimizes a simpler distributionScales to large dataOften underestimates variance
Laplace approximationGaussian at the modeCheap given the MAPPoor for skewed posteriors
Expectation propagationLocal moment matchingGood marginalsMay fail to converge
Methods for obtaining the posterior

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.

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.

ConceptOutputUses priorCaptures parameter uncertainty
Posterior distributionFull distributionYesYes, directly
Maximum likelihood estimateSingle valueNoOnly via sampling theory
MAP estimateSingle valueYesNo
Prior distributionFull distributionIs the priorBefore data only
Posterior distribution versus related concepts

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.