Bayesian inference

On this page 7

Bayesian inference is a method of statistical reasoning that treats unknown quantities as random variables with probability distributions and updates those distributions with Bayes’ theorem as new data is observed. Within probabilistic models in artificial intelligence, it is the principle that turns a prior distribution and a likelihood into a posterior distribution, which expresses everything the model believes about its parameters after seeing the evidence.

Its defining feature is that the result is a full distribution, not a single estimate. Instead of reporting one best parameter value, Bayesian inference reports how plausible every value is, which makes uncertainty quantification a built-in output rather than an afterthought.

How Bayes’ theorem drives the update

Bayesian inference rests on one identity: the posterior is proportional to the likelihood times the prior. Written in full, p(θ | D) = p(D | θ) p(θ) / p(D), where θ denotes the parameters and D the observed data.

ComponentNotationRole in the update
Prior distributionp(θ)Encodes belief about θ before seeing data
Likelihoodp(D | θ)Measures how well each θ explains the data
Marginal likelihoodp(D)Normalizes the result; also called the evidence
Posterior distributionp(θ | D)Updated belief about θ after seeing data
Posterior predictivep(x* | D)Prediction for new data, averaged over θ
Components of Bayes’ theorem in parameter inference

The update is naturally sequential: today’s posterior becomes tomorrow’s prior. With independent observations, processing the data in batches or all at once gives the same posterior, which makes Bayesian inference well suited to streaming and online learning. As the amount of data grows, the likelihood dominates and the influence of a reasonable prior fades.

Exact and approximate inference methods

Computing the posterior exactly is possible only in special cases, because the marginal likelihood requires an integral over all parameter values that is usually intractable in high dimensions. Practitioners therefore choose among exact, sampling and optimization-based methods.

MethodHow it worksStrengthWeakness
Conjugate analysisClosed-form posterior for matching prior and likelihoodExact and instantLimited to simple models
Markov chain Monte CarloDraws correlated samples from the posteriorAsymptotically exactSlow; convergence hard to verify
Hamiltonian Monte CarloUses gradients to propose distant movesEfficient in many dimensionsNeeds differentiable models
Variational inferenceFits a simple distribution by maximizing the ELBOFast and scalableUnderestimates posterior variance
Laplace approximationFits a Gaussian at the posterior modeCheap and simplePoor for skewed or multimodal posteriors
Main families of Bayesian inference algorithms

The choice is a trade-off between accuracy and computation. For models with tens or hundreds of parameters, gradient-based samplers such as the No-U-Turn Sampler are the default in probabilistic programming tools. For millions of parameters, as in Bayesian neural networks, variational methods or cheaper approximations such as deep ensembles and Monte Carlo dropout are common.

Bayesian inference compared with point estimation

Bayesian inference differs from maximum likelihood estimation and maximum a posteriori estimation mainly in what it returns. Both alternatives produce one parameter value, while the Bayesian approach keeps the whole distribution and averages predictions over it.

ApproachOutputUses a priorCaptures uncertainty
Maximum likelihood estimationSingle θ maximizing p(D | θ)NoOnly through separate methods
Maximum a posteriori estimationSingle θ maximizing the posteriorYesNo
Full Bayesian inferenceEntire posterior distributionYesYes, epistemic uncertainty
Bayesian inference versus point estimation

With abundant data, the three approaches usually agree closely. The differences matter with small or noisy datasets, many parameters, or decisions where the cost of overconfidence is high. A MAP estimate with a Gaussian prior is mathematically equivalent to L2 regularization, which shows that many familiar regularization techniques have a Bayesian reading.

Choosing priors and checking models

The prior is the most debated element of Bayesian inference, yet in practice it is a modeling decision like any other and should be justified and tested. Priors range from strongly informative, based on earlier studies, to weakly informative priors that only rule out implausible values.

  • Weakly informative priors keep estimates in a sensible range without dominating moderate amounts of data.
  • Conjugate priors give closed-form updates, for example a Beta prior with a binomial likelihood.
  • Hierarchical priors share strength across groups, so sparse groups borrow information from richer ones.
  • Prior predictive checks simulate data from the prior alone to reveal unrealistic assumptions before fitting.

After fitting, posterior predictive checks compare simulated data with the observed data, and diagnostics such as the R-hat statistic and effective sample size confirm that sampling has converged. Skipping these checks is the most common source of confident but wrong Bayesian results.

Limitations and common misconceptions

Bayesian inference is principled, but it is not automatically correct. Its conclusions are only as good as the model, and several misunderstandings recur in applied work.

ProblemCauseRemedy
Posterior too narrowMisspecified likelihood or variational biasCheck model fit; compare with sampling
Results driven by the priorLittle data and a strong priorRun a prior sensitivity analysis
Sampler does not convergePoor parameterization or multimodalityReparameterize; run several chains
Excessive compute timeExact sampling on a large modelUse variational or amortized inference
Frequent problems in applied Bayesian inference

A common misconception is that Bayesian methods are subjective and therefore unscientific. Every statistical method embeds assumptions; the Bayesian approach simply makes them explicit in the prior, where they can be inspected, criticized and tested.

In everyday language

Bayesian inference is a careful way to change your mind. You start with a belief. Then you see new evidence. You adjust the belief in proportion to the evidence. Strong evidence moves it far. Weak evidence moves it a little.

Imagine guessing whether it will rain. You begin with what is normal for the season. Then you see dark clouds, and your estimate rises. The method also tells you how sure you should be, not just what to guess. That honesty about doubt is its main advantage.

Seen in the real world

An online retailer runs an A/B test on a new checkout page. After three days, version A has 120 purchases from 4,000 visitors and version B has 141 from 4,000. A classical test gives an inconclusive p-value, and the product team wants a clearer basis for deciding.

The analytics team applies Bayesian inference with a Beta prior on each conversion rate, set from the site’s historical range of 2 to 5 percent. The Beta-binomial update yields posterior distributions for both versions, and sampling from them shows that version B is better with about 91 percent probability, with an expected uplift of roughly half a percentage point.

Because the posterior also quantifies the expected loss of choosing B if it is actually worse, the team sets a clear stopping rule and ships version B after two more days of data confirm the estimate.