Introduction to Bayesian Inference
Bayesian Inference
From observed data to an explanation
Statistical inference aims to learn about the process that produced observed data. Suppose an experiment produces data x. The process that generated it is unknown, so an analyst makes a likelihood assumption: the data are modeled as arising from a probability distribution or probability mass function indexed by a parameter θ.
For example, the model might state that observations follow a distribution f(x∣θ). The inferential question is then: given the observed data, what values of θ are plausible? Learning about θ helps describe the assumed data-generating process.
A model’s assumptions are not necessarily the only possible explanation of the data. Another analyst might propose a competing process, such as g(x∣λ), with a different parameter λ. Each model can be fitted to the observed data, then assessed by how well it explains or predicts new, unseen data. A model that predicts future data better may be considered closer to the underlying generative process.
Bayes’ theorem as a rule for updating
For mutually exclusive and exhaustive events A1,…,AN, Bayes’ theorem gives
The numerator combines how likely the evidence B is under A1 with the prior probability of A1. The denominator sums this quantity across all possible events, accounting for all ways the evidence could have arisen.
In parameter inference, the possible values of θ take the place of the possible events. The objective is to update knowledge about θ after observing data x.
Why represent a parameter with a distribution?
Uncertainty in parameter estimates
A limited sample rarely identifies one parameter value with complete certainty. Several values of θ may plausibly have produced the same observed data, though some may be more plausible than others.
For instance, the data might make θ=0.6 seem most plausible while still being compatible with θ=0.5. Reporting only a single estimate—such as a maximum-likelihood estimate—hides this uncertainty and the other values that remain possible.
Bayesian inference represents uncertainty by treating the parameter as a random variable with a probability distribution. The goal is therefore not only to select a point estimate, but to estimate how probability is distributed across possible values of θ.
Posterior uncertainty depends on the observed data
The distribution of θ after observing data depends on what was observed. Different data could lead to different conclusions about the parameter. Bayesian inference therefore estimates the conditional distribution of the parameter given the observed data, rather than claiming to know the parameter with certainty.
The four components of Bayesian inference
For a parameter θ and observed data x, Bayes’ theorem is
Likelihood: p(x∣θ)
The likelihood describes how compatible the observed data are with a particular value of θ, under the assumed data-generating model.
Once the data x have been observed, they are held fixed. The likelihood is then evaluated across different values of θ. For example, one can compare the model’s likelihood at θ1 with its likelihood at θ2 to see which value makes the observed data more compatible with the model.
The same quantity can be written as a likelihood function, often denoted L(θ;x). This notation emphasizes that the observed data are fixed while the function varies with θ.
The likelihood is not generally a probability distribution over parameter values. It measures how well different parameter values account for the fixed observed data.
Prior distribution: p(θ)
The prior distribution represents information or assumptions about θ before the current data are used. A prior may reflect knowledge from previous studies, subject-matter expertise, or a reasonable constraint on possible parameter values.
For example, in an experiment measuring the probability of correctly recognizing a word, prior knowledge might suggest that the probability of a correct response is usually between 0.6 and 1. This expectation can be represented with a prior distribution that assigns more probability to that range.
A prior is not a conclusion drawn from the current data. It is an input to the analysis and should be chosen with the context of the problem in mind.
Marginal likelihood: p(x)
The marginal likelihood, also called the evidence, measures the overall probability density of the observed data under the model after averaging across possible parameter values.
For a continuous parameter,
For a discrete parameter, the corresponding calculation is a sum over possible parameter values. This term follows from the law of total probability.
For a fixed dataset and model, the marginal likelihood is a normalizing constant: it does not vary with θ. Dividing by it ensures that the posterior is a proper probability distribution whose total probability is 1.
Posterior distribution: p(θ∣x)
The posterior distribution describes uncertainty about θ after observing the data. It combines the likelihood and prior, then normalizes the result:
The posterior indicates which parameter values are more or less plausible given both the observed data and the prior assumptions. It is the central result of Bayesian parameter inference.
Posterior calculation and normalization
A practical way to understand the calculation is to imagine evaluating it across a range of parameter values:
Choose a candidate value of θ.
Evaluate how well that value accounts for the observed data using the likelihood.
Evaluate how plausible that value was before seeing the data using the prior.
Multiply the likelihood and prior values.
Normalize the resulting values so they form a probability distribution.
Before normalization, the product is proportional to the posterior:
This is an unnormalized posterior. It preserves the relative plausibility of parameter values but does not necessarily integrate to 1. The marginal likelihood supplies the normalization constant when a fully normalized posterior is needed.
The likelihood is calculated from the assumed probability model. If the model specifies a density or mass function f(x∣θ), then that function supplies the likelihood values for the observed data across different candidate values of θ.
Making the modeling assumptions
Bayesian inference requires at least two kinds of assumptions.
Likelihood assumption
The likelihood assumption specifies the form of the data-generating model: how the observed outcomes are modeled as depending on parameters. For example, an analyst might assume that the observations follow a normal distribution with mean μ and standard deviation σ.
This assumption defines how to calculate the likelihood. If the assumed model is a poor description of the data-generating process, the resulting inference may also be misleading.
Prior assumption
A prior assumption specifies a distribution for each unknown parameter before the current data are observed. In the normal-model example, priors are needed for both μ and σ.
A prior for the mean might express that values in a particular interval are more plausible than values far outside it. A prior for the standard deviation must respect the fact that a standard deviation is positive; a distribution restricted to positive values could be used.
When there are multiple parameters, the analysis uses a joint prior distribution for them. Treating separate prior distributions as independent is an additional assumption, not an automatic consequence of assigning each parameter its own prior.
A step-by-step inference workflow
For a model involving data y and parameters μ and σ, the general process is:
Specify the likelihood model. State how the observations are assumed to arise, such as from a normal distribution with parameters μ and σ.
Specify prior distributions. Assign prior distributions to the unknown parameters, taking account of relevant knowledge and parameter constraints.
Collect or identify the observed data. The observed dataset is treated as fixed when evaluating the likelihood.
Calculate the likelihood. Evaluate how compatible different parameter values are with the observed data under the model.
Combine likelihood and prior. For each candidate parameter value or combination of values, multiply the likelihood by the prior density.
Normalize if needed. Calculate or approximate the marginal likelihood so that the result is a proper posterior distribution.
For two parameters, the posterior is a joint distribution:
If the prior explicitly assumes that μ and σ are independent, then the joint prior can be written as p(μ,σ)=p(μ)p(σ). Otherwise, the prior should remain expressed as a joint distribution.
Interpreting and using the posterior
The posterior retains information that a single point estimate cannot show. It represents a range of plausible parameter values and indicates how plausibility varies across that range. A point estimate may still be calculated from the posterior for a particular purpose, but it should not be mistaken for the entire inferential result.
The posterior is conditional on both the observed data and the assumptions used to construct the analysis. Different data can produce different posterior distributions, and different likelihood or prior assumptions can also change the result.
Once parameter uncertainty has been estimated, the fitted model can be used to make predictions about future or unseen data. Comparing competing models by their predictive performance provides a way to assess which assumed generative process better explains observations beyond the data used to fit it.

Ask anything
We've read this whole study set, so questions about it get the best answers.