Parameters as distributions rather than points
The frequentist treats a parameter as fixed but unknown and the data as random; the Bayesian treats the data as fixed and the parameter as uncertain, encoding that uncertainty with a probability distribution. The difference sounds philosophical and is instead practical. A distribution for the parameter carries how confident you were before seeing data, how much the data moved you, and how much doubt remains afterward â three things a single point estimate cannot express at once.
The payoff shows up most clearly when data are scarce. With ten observations the prior contributes real information, and the analyst must therefore state it, justify it, and preferably show that conclusions survive reasonable alternatives. With ten thousand observations the likelihood overwhelms almost any non-extreme prior, and both schools converge on the same answer. This is not a weakness: it is the correct behaviour for a system that is supposed to learn from evidence, and it makes prior choice something to report and stress-test rather than hide.
Bayes' rule for parameters
Posterior equals likelihood times prior, normalised by the evidence. The evidence â the probability of the data averaged over all parameter values â acts only as a normalising constant, which is why nearly every practical computation proceeds with the unnormalised posterior and renormalises at the end. What remains is a product of two competing influences: the likelihood describes what the data support, and the prior describes what was believed beforehand.
Normalisation is also where computation gets hard. For simple models the integral can be evaluated in closed form; for anything realistic it is a high-dimensional integral with no analytic solution, which is the entire reason Markov chain Monte Carlo and variational methods exist. Conceptually, though, nothing complicated happens: you multiply, you normalise, and the shape of the result tells you what to believe. Prior and likelihood are in genuine tension when they disagree, and the posterior settles that tension in proportion to how much information each side carries.
Conjugate priors and closed-form updates
A prior is conjugate when multiplying it by the likelihood returns a distribution of the same family, so the posterior is read straight off the parameters. The beta prior is conjugate to binomial data: observing successes simply adds them to the alpha parameter and failures to beta, which gives the update a beautiful bookkeeping interpretation â the prior acts like a number of pseudo-observations you already had. The normal prior is conjugate to a normal mean, the gamma prior to a Poisson rate, and the normal-inverse-gamma to the full normal model with unknown mean and variance.
| Likelihood | Conjugate prior | Posterior update | Typical use |
|---|---|---|---|
| Bernoulli or binomial | Beta | Add successes to alpha, failures to beta | Click rates, conversion, A/B tests |
| Normal mean, known variance | Normal | Precision-weighted average of prior and data | Measurement, hierarchical means |
| Poisson rate | Gamma | Add counts to shape, add exposure to rate | Event counts per interval |
| Normal with unknown mean and variance | Normal-inverse-gamma | Joint update of both parameters | Full normal model |
| Multinomial | Dirichlet | Add category counts to each component | Topic mix, market shares |
Outside conjugate families the posterior still exists but must be approximated. The trade-off is between analytical convenience and modelling freedom: conjugate models are transparent and fast but restrict the shapes you can express, while simulation-based approaches accept any model at the price of convergence diagnostics and computation.
MAP estimation: where Bayesian meets regularised
The maximum a posteriori estimate is simply the mode of the posterior, the most probable parameter value given the data. Because the normalising constant does not affect location, maximising the posterior is equivalent to maximising the likelihood times the unnormalised prior, which splits into a data-fit term and a prior term. With a Gaussian prior centred at zero, the prior term becomes a squared penalty on the coefficient â exactly ridge regression. With a Laplace prior it becomes an absolute-value penalty, exactly lasso.
That identity is the bridge between the two schools. Regularisation, which a frequentist motivates as variance reduction or feature selection, is the same operation as a Bayesian stating that large coefficients were unlikely in advance. The prior variance sets the regularisation strength: an infinitely diffuse prior makes the mode coincide with the maximum likelihood estimate, and a tight prior pulls the estimate hard toward zero. Understanding this lets you choose penalty strength by asking a Bayesian question â how big a coefficient would surprise you â rather than by blind grid search.
Credible intervals versus confidence intervals
A ninety-five percent credible interval is a statement about where the parameter lies: there is a ninety-five percent probability, given the data and the prior, that the true value falls inside it. A ninety-five percent confidence interval is a statement about the procedure: ninety-five percent of intervals constructed this way would contain the fixed parameter, but for the interval in front of you no probability is asserted. The credible interval permits the sentence people actually want to write, and the confidence interval does not.
Practically, credible intervals come straight from the posterior â read the two and a halfth and ninety-seventy-fifth percentiles of the samples â and they do not require asymptotic approximations, which makes them reliable for small samples and small probabilities where normal approximations break down. They also carry asymmetry honestly: a posterior that trails off to the right yields an interval wider on the right, whereas a Wald interval built from a standard error forces symmetry that the data do not support. Reporting both a posterior median and a credible interval gives a compact and honest summary of what was learned.
Posterior computation in Python
import numpy as np
def beta_posterior(alpha0, beta0, successes, failures, grid=None):
"""Unnormalised beta posterior evaluated on a grid."""
if grid is None:
grid = np.linspace(0.001, 0.999, 2000)
a = alpha0 + successes
b = beta0 + failures
log_post = ((a - 1) * np.log(grid) + (b - 1) * np.log(1 - grid))
log_post -= log_post.max()
post = np.exp(log_post)
post /= np.trapz(post, grid)
return grid, post, a, b
def summarize(grid, density, cred=0.95):
cdf = np.cumsum(density)
cdf /= cdf[-1]
lo = np.interp((1 - cred) / 2, cdf, grid)
hi = np.interp(1 - (1 - cred) / 2, cdf, grid)
mean = np.trapz(grid * density, grid)
return mean, lo, hi
grid, post, a, b = beta_posterior(2, 2, successes=7, failures=3)
mean, lo, hi = summarize(grid, post)
print(f"prior Beta(2,2), data 7/10 -> posterior Beta({a}, {b})")
print(f"posterior mean = {mean:.3f}, 95% credible interval "
f"= [{lo:.3f}, {hi:.3f}]")
print(f"MLE = {7 / 10:.3f} (the data alone)")
for alpha0, beta0, s, f in ((1, 1, 7, 3), (20, 20, 7, 3), (1, 1, 70, 30)):
_, _, a, b = beta_posterior(alpha0, beta0, s, f)
print(f"prior Beta({alpha0},{beta0}) with {s}/{s + f}: "
f"posterior mean {(a / (a + b)):.3f}")
The first block shows the moderate prior pulling the estimate toward one half while the data pull toward seven tenths. The last three lines make the learning dynamic visible: with the same prior, quadrupling the data shrinks the prior's influence, and a very strong prior barely moves even with a hundred observations.
The second block connects the Bayesian view to regularised regression and shows posterior sampling for a normal mean.
import numpy as np
def map_ridge(X, y, lam=1.0):
"""MAP estimate with a Gaussian prior on coefficients equals ridge."""
n, p = X.shape
A = X.T @ X + lam * np.eye(p)
return np.linalg.solve(A, X.T @ y)
def normal_posterior(prior_mean, prior_var, data, sigma):
"""Closed-form posterior for a normal mean with known observation sd."""
n = data.size
post_precision = 1 / prior_var + n / sigma ** 2
post_var = 1 / post_precision
post_mean = post_var * (prior_mean / prior_var + data.sum() / sigma ** 2)
return post_mean, post_var
rng = np.random.default_rng(31)
n, p = 80, 6
X = rng.normal(size=(n, p))
true = np.array([2.0, 0.0, 0.0, 1.5, 0.0, 0.0])
y = X @ true + rng.normal(0, 1.0, n)
ols = np.linalg.lstsq(X, y, rcond=None)[0]
ridge = map_ridge(X, y, lam=5.0)
print("true :", np.round(true, 2))
print("OLS :", np.round(ols, 2))
print("MAP/ridge :", np.round(ridge, 2))
measurements = rng.normal(10.4, 1.0, size=12)
mu, var = normal_posterior(prior_mean=8.0, prior_var=4.0,
data=measurements, sigma=1.0)
print(f"posterior mean = {mu:.3f}, sd = {np.sqrt(var):.3f}")
print(f"95% credible interval = [{mu - 1.96 * np.sqrt(var):.3f}, "
f"{mu + 1.96 * np.sqrt(var):.3f}]")
The ridge coefficients sit between the true values and the least-squares ones, which is precisely what a shrinkage prior should do when the data alone overfit. The conjugate normal update at the end produces an interval that can be read as a probability statement directly, with no long-run reinterpretation required.
Bayesian habits that go wrong
Common Mistakes
Choosing a prior to obtain a preferred conclusion
Fix: Pre-register the prior and show a sensitivity analysis across at least weakly informative alternatives.
Using an extremely strong prior on scarce data
Fix: Check how many effective pseudo-observations the prior contributes before trusting the posterior.
Reading a credible interval as a confidence interval
Fix: They answer different questions; the credible interval carries a probability about the parameter, the confidence interval does not.
Reporting a posterior from a chain that has not converged
Fix: Inspect trace plots, rank plots, and the rank-normalised split R-hat before quoting any summary.
Treating the MAP estimate as a full posterior summary
Fix: The mode discards spread and asymmetry; report the posterior distribution or at least an interval.
Forgetting that a flat prior is itself an assumption
Fix: A uniform prior is informative on a bounded scale; state it explicitly and test alternatives.
Best Practices
- State the prior in terms of plausible values so subject-matter reviewers can judge it.
- Run a prior sensitivity check whenever the sample size is small.
- Diagnose MCMC with R-hat near one and effective sample size well above a few hundred.
- Report posterior medians and credible intervals rather than point estimates alone.
- Connect the prior to the regularisation you already use; the two are the same modelling choice.
Bayesian essentials
Where to go next
- Bayesian Regression places distributions over regression coefficients.
- Hierarchical Bayesian Models introduces partial pooling and shrinkage across groups.
- MCMC Diagnostics covers trace plots, effective sample size, and the R-hat statistic.
- Decision Theory turns posterior beliefs into optimal actions under loss.