Bayesian model evidence Created 2026-09-24 Updated 2026-10-18
The Bayesian model evidence is the prior predictive distribution evaluated at the data . For a statistical model with a normalized prior density , its marginal likelihood isThis is an expected value of the likelihood function under the prior distribution; for discrete statistical parameters, replace the integral by a sum. For continuous observations, is a probability density function value with respect to a specified data reference measure, rather than a probability of one exact observation. Comparisons must use the same data and reference measure. The same normalizes the within-model Bayesian posterior and supplies the between-model comparison in a Bayes factor.[ref]
Bayes Factors by Robert E. Kass and Adrian E. Raftery. Kass and Raftery, Bayes Factors (1995), section 3.1, p. 776, equations (1)–(2): integrating over parameter priors
A normalized prior distribution makes the Bayesian model evidence an average, so it cannot exceed the largest likelihood function value on its support. A broad prior distribution can assign little mass to values that predict the data well, even when one value gives an excellent fit. The worked uniform-alternative binomial Bayes factor below makes the difference between averaging and maximum likelihood estimation explicit.
Bayesian posterior Created 2026-09-24 Updated 2026-10-14
The Bayesian posterior is the conditional probability distribution of an unknown statistical parameter after observing data. Suppose a continuous prior distribution has prior density relative to Lebesgue measure , and is the sampling probability mass function or probability density function of the observed data in the statistical model. Bayes' theorem givesThe Bayesian model evidence is the normalization constant making the posterior density integrate to one. The strict positive, finite condition is essential: a zero or infinite normalizer does not define this posterior distribution, even if the unnormalized expression can be written down. Other reference measures give the corresponding density formula; discrete parameter values replace the integral by a sum. The posterior propriety article gives examples where normalization fails.
With fixed, is a likelihood function of . Its normalization as a sampling distribution is over possible data, not over parameter values. In particular, a likelihood function is not a probability density function for and need not integrate to one over . The prior density supplies the probability weighting, and the Bayesian model evidence normalizes their product. This distinction prevents a tempting mistake: reversing the conditioning merely by exchanging the words “data” and “parameter”.
For eight heads among ten conditionally independent Bernoulli trials, take the observed data to be the heads count . Its binomial distribution likelihood function and the prior density giveUsing the Euler beta function , the Bayesian model evidence and normalized posterior density areThus the posterior distribution is . If the data are instead one particular ordered sequence with eight heads and two tails, its likelihood function omits the factor 45 and its Bayesian model evidence becomes . The factor cancels in Bayes' theorem, leaving the same posterior distribution; these two data descriptions have different sampling probabilities but identical information about here.
Beta(2,2) prior, peak-normalized Bernoulli likelihood, and Beta(10,4) posterior after eight heads and two tails
. Details. The prior density and posterior density use the left axis and each integrate to one. The dashed likelihood function uses the right axis and is divided by its maximum solely to compare its shape; it is not a parameter probability density function. The likelihood function peaks at , while the posterior mode is and the posterior mean is . Multiplying by the prior density shifts the preferred values toward one half while preserving a range of possibilities.
The resulting posterior variance is , compared with prior variance . In this example the update reduces uncertainty. The posterior predictive probability of heads on the next conditionally independent toss is , and the credible interval above reports a 95% range. These are summaries of the same posterior distribution, rather than competing estimates of one density peak.
Jeffreys prior for a Bernoulli parameter 2026-10-25
For a Bernoulli random variable with success probability , the score function is . The expected value of its square is , since the variance of is . The Jeffreys prior is therefore the proper beta distribution , also called the arcsine distribution. The Euler beta function has , giving the stated normalized prior density.
After successes in independent Bernoulli trials, Beta-binomial conjugacy gives posterior distribution and posterior predictive probability of one further success. Although its prior density diverges at both boundaries, its integral is finite.
Likelihood function Created 2026-09-24 Updated 2026-10-14
For a fixed observed sample , a likelihood function iswhere is the probability mass function or probability density function of the observations under the statistical parameter . All densities must be defined relative to the same parameter-independent dominating measure. The sample is fixed; the parameter is the function's argument. With independent and identically distributed random variables, the joint mass or density factors as . This definition and the distinction between sampling probability and parameter uncertainty are explained in MIT 18.05, Reading 10b, sections 3 and 3.2.
For an observed ordered sequence of ten independent Bernoulli trials containing eight successes and two failures, each success contributes and each failure contributes , givingIf the observation is instead only the total count , its binomial distribution probability mass function sums over the possible ordered sequences:The raw heights differ: at they are approximately and . Their maximum-likelihood estimates are identical. More generally, multiplication by any finite positive constant independent of leaves the maximizing parameter values and all likelihood ratios unchanged. Multiplication by a parameter-dependent factor can change the MLE; dropping such a factor is not justified. Relative likelihood height sets the peak to one, without making the area under the curve one.
Normalization of is over possible data values for each fixed parameter. It imposes no requirement that . For example, the ordered Bernoulli trials likelihood above hasIts integral is not one, and its values are not posterior probabilities for . When the Bayesian posterior is defined, Bayes' theorem multiplies the likelihood by a prior density and normalizes that product. Choosing to normalize a likelihood function alone is an additional choice, such as using a uniform prior in those parameter coordinates, rather than part of the definition of likelihood.
For observations with a probability density function, the probability of an exact sample point is zero. If a scalar density is continuous at the observed value , thenThus the density compares probabilities of small, equal observation intervals at different parameter values; it is not itself the probability of that exact real number. The equal-width factor is independent of the parameter. This gives visual intuition for density likelihoods, as in MIT 18.05, Reading 10b, section 4. The normal distribution example in maximum-likelihood estimator makes the comparison explicit. If only rounded intervals are recorded, their integrated probabilities give the exact observation likelihood; using midpoint densities is an approximation.
Likelihood weighting 2026-10-25
Likelihood weighting uses observation likelihoods as importance weights. If parameters are drawn independently from their prior distribution , weight a draw by and estimate a posterior expectation of by . With positive finite evidence and integrable weighted quantities, the strong law of large numbers proves consistency of this self-normalized importance sampling ratio. Finite-sample bias and concentration of the weights remain possible. A different proposal requires the additional prior density-to-proposal density ratio.
Mixed Poisson distribution 2026-10-14
A mixture of Poisson distributions over a nonnegative random intensity. With exposure and prior density , its probability mass function is . A gamma mixing distribution gives a negative binomial distribution. Counts sharing the same latent intensity are conditionally independent, but generally dependent after mixing.
The marginal likelihood integrates the likelihood function against the prior density:It is the normalizing constant in Bayes' theorem. For the subsequent posterior distribution and importance sampling calculations, assume a normalized prior density and .
The beta distribution prior density is proportional to . By Bayes' theorem, its product with the likelihood function gives the posterior densityThis is again a beta distribution, namelyThus the beta family is a conjugate prior family for the geometric distribution. The update is an instance of beta-geometric conjugacy: counts of observed successes and failures are added to the two beta parameters.
Past exam of the mathematics course of the University of Cambridge 2001 iii Paper 32 6 i Solution Created 2026-10-03 Updated 2026-10-14
An Edgeworth expansion refines a central normal approximation using higher cumulants. Let be independent and identically distributed, with mean , positive variance , and cumulants . DefineThe logarithm of its characteristic function has the expansionExpanding the exponential adds the squared cubic term . Fourier inversion turns into , where the probabilists' Hermite polynomials satisfyThus the density Edgeworth expansion through order isHere , , and . Since , the corresponding cumulative distribution function expansion isThese remainder statements require adequate moments and smooth nonlattice conditions allowing transform inversion and error control, not merely a formal cumulant expansion. The density version needs the corresponding local smoothness. A symmetric distribution has , removing the first correction. Truncation can produce negative densities or nonmonotone distribution functions far from the center; it is not automatically a uniformly reliable relative tail approximation. A lattice distribution needs its lattice correction.
A Laplace approximation instead approximates an integral dominated by a sharp maximum. Suppose has a unique interior maximizer , with positive definite, and the integral is localized near that point. For smooth amplitude ,Set . A Taylor expansion givesExpanding and integrating the resulting Gaussian integral givesUnder sufficient smoothness and localization the relative correction is : odd terms of order integrate to zero over the limiting symmetric Gaussian region. Higher terms use derivatives of and Gaussian moments.
For a likelihood function with and a smooth positive prior density, this gives the integrated likelihood approximationwhere is the observed information. Ratios of such integrals give posterior expectation by Laplace approximation; the same method is useful when integrating nuisance variables. Boundary maxima, singular Hessian matrices, nonlocalized tails and several dominant modes require altered formulas, with contributions summed when appropriate.
Both methods start with a quadratic Gaussian approximation and then retain higher-order terms. The Edgeworth series corrects a sampling distribution through its cumulants and Fourier inversion; Laplace's method corrects an integral through local derivatives at its dominant point. Neither should be confused with simply replacing a likelihood by a normalized posterior density.
Past exam of the mathematics course of the University of Cambridge 2006 iii Paper 42 6 Solution Created 2026-10-03 Updated 2026-10-20
Let . Near the interior minimum, Taylor expansion givesOn the scale , the leading exponent is and . If the integral is localized at this minimum, the rescaled integration endpoints tend to infinity in both directions, so the Gaussian integral gives Laplace's method:Formally expanding the cubic term gives an order- correction odd in , whose Gaussian integral is zero. Quartic terms and the square of the cubic term produce the order- correction. Sufficient smoothness near the minimum and control of the exterior integral justify this formal calculation.
The printed local assumptions alone do not guarantee localization. A useful localization condition for Laplace's method is that outside each sufficiently small fixed neighbourhood of , for some , and that for some . For , the exterior contribution is at mostwhich is exponentially smaller than the displayed local term. To see why something of this kind is needed, take on . Its unique minimum is at zero and , yet on we have . This boundary interval alone contributes at least , dominating the proposed local approximation. The Laplace formula therefore has its usual implicit tail assumption, rather than following from uniqueness of the interior minimum alone.
For the gamma function, set to obtainHere has its unique minimum at , with and . It tends to infinity at both endpoints, and its integral is finite for positive exponents, so localization holds. Laplace's method yields Stirling's formula:
For a prior density and independent observations, Bayes' theorem writes the desired posterior expectation as a ratio of integrals:Suppose the log-posterior kernel has a unique concentrating interior mode , with curvature of order , and the smoothness and tail conditions hold for both integrals. Expanding quadratically gives a common Gaussian factor . Replacing the smooth amplitude by givesThis approximation does not require to be positive: it treats as an amplitude, without taking its logarithm. For more accuracy, expand the amplitude and the cubic term in the log-posterior kernel. With , the Gaussian moments are and . Terms multiplying cancel between numerator and denominator; the two remaining first corrections areunder the stronger smoothness, derivative-scaling and integrability assumptions needed for this expansion. The first term accounts for the curvature of the amplitude and the second for posterior skewness. This is posterior expectation by Laplace approximation. If there are several modes, boundary modes, or nonconcentrating tails, the appropriate separate contributions must be included; a single interior Gaussian approximation cannot then be assumed.
Past exam of the mathematics course of the University of Cambridge 2006 iii Paper 45 4 c Solution Created 2026-10-03 Updated 2026-10-14
Assume , , a proper prior density supported on nonnegative mutation rates, and independence of the mutation-rate prior from the neutral genealogy. PutBy Bayes' theorem, the joint posterior isThe normalizing constant is the prior predictive probability and must be positive. For , interpret the factor as 1 even at zero. If , there are no segregating sites: surely, so that case supplies no information about .
Past exam of the mathematics course of the University of Cambridge 2006 iii Paper 45 4 d Solution Created 2026-10-03 Updated 2026-10-14
Use Bayesian rejection sampling for a segregating-site count. Independently propose and for , and calculate . Draw an independent uniform on and accept the whole proposed vector exactly whenRepeat after a rejection. The right side is a probability mass function value of a Poisson distribution and is therefore between zero and one. On acceptance, the probability density function of a proposed vector is its prior density multiplied by this acceptance probability, divided by the probability of acceptance. Part (c) shows that this is precisely . Independent proposals and uniforms produce independent posterior draws. Equivalently, one could simulate a count from a Poisson distribution with mean and retain the proposal when that count equals ; the uniform version avoids simulating that extra count.
Past exam of the mathematics course of the University of Cambridge 2006 iii Paper 45 4 g Solution Created 2026-10-03 Updated 2026-10-14
The accepted mutation parameters have marginal probability density functionEstimate this probability density function with a suitably smoothed histogram or a boundary-aware kernel density estimator from the accepted draws. On a parameter region where , divide the estimate by the known prior density and maximize:The unknown is constant in and cancels. Maximizing the posterior density itself gives a posterior mode, not generally a maximum-likelihood estimate; the two coincide for a flat prior on a region containing the maximum. A prior excluding candidate maximizers cannot recover them through its posterior output. Boundary behavior also matters: for , the likelihood is decreasing in , so the unrestricted maximum is at .
The exact likelihood provides a useful independent check. Put . Its Laplace transform is , since is exponential of rate . The probability density functionhas that same transform: substitute to obtain . Thus, expanding its binomial factor and integrating each term,This is the segregating-site likelihood under the neutral coalescent. It can be maximized numerically to check the posterior-density estimate; the generating-function representation avoids cancellation in large alternating sums. For , it reduces to , whose maximum is at for .
Alternatively, differentiating the integrated likelihood givesAn interior maximum therefore satisfies . Conditional expectations of can be estimated by smoothing the accepted pairs near each candidate parameter value, yielding another simulation-based score equation. The simple estimator is the unbiased Watterson estimator from part (b), and is not generally the likelihood maximizer.
Past exam of the mathematics course of the University of Cambridge 2009 iii Paper 36 1 a Solution Created 2026-10-03 Updated 2026-10-14
The binomial likelihood is . Multiplication by the beta distribution prior density and Bayes' theorem give the posterior density kernel . Normalizing by the beta function yields Beta-binomial conjugacy:This is proper for and , including counts at either boundary.
Past exam of the mathematics course of the University of Cambridge 2009 iii Paper 36 3 d Solution Created 2026-10-03 Updated 2026-10-14
The regression coefficients have independent proper uniform distributions on very wide finite intervals. These are flat in the coefficients, not flat in fitted rates, and can be highly informative on the rate scale. The scale is uniform on , and WinBUGS receives the corresponding precision for each normal distribution random effect. Writing , the induced prior density isIt is proper and integrable at zero.
The usual scale-invariant variance prior would instead cause an improper posterior from a log-uniform random-effect scale prior. After integrating out the plate effects, the likelihood function tends as to the ordinary positive Poisson likelihood. On any compact interior set of coefficient values this limit is positive and bounded away from zero. Hence the posterior normalizing integral contains a divergent factor . There is no posterior distribution under that prior, even if formal full conditional distributions appear usable. Thus a proper prior with integrable mass near zero is needed here. The reciprocal-scale rule is the standard pure-scale Jeffreys prior; it should not be confused with the model-specific information prior for an additive variance component.
Past exam of the mathematics course of the University of Cambridge 2010 iii Paper 36 2 f Solution Created 2026-10-03 Updated 2026-10-14
The new prior density contributes the factor . Multiplication by the Poisson distribution likelihood givesIts posterior mean displays the resulting shrinkage:The observed risk ratio is pulled towards one, most strongly for small exposures. The posterior variance is .
Past exam of the mathematics course of the University of Cambridge 2010 iii Paper 36 3 b Solution Created 2026-10-03 Updated 2026-10-14
Under the usual regular, identifiable, fixed-dimensional setting, the maximum-likelihood estimator is an interior point with vanishing log-likelihood gradient, and the observed information is positive definite. DefineThe second-order Taylor expansion of the Bayesian deviance isWith a prior density approximately constant over the likelihood's concentration region, the posterior density is therefore proportional toRecognizing the multivariate normal density givesTypically grows at rate and the posterior concentrates in a region of radius , making higher-order terms negligible under the regularity assumptions. The local flatness assumption concerns this region, not necessarily the entire parameter space. Boundary maxima, unidentified directions, or persistent multiple modes can invalidate this approximation.
Past exam of the mathematics course of the University of Cambridge 2013 iii Paper 29 4 Solution Created 2026-10-03 Updated 2026-10-07
The reversible-jump Markov chain Monte Carlo state comprises the model index and that model's parameter. Its unnormalized posterior density in model isFor models of equal dimension, choose model with probability and propose using density on the destination parameter space. The equal-dimension reversible-jump acceptance probability isOn acceptance change both model and parameter; on rejection retain both. Choose model proposals connecting all models of positive posterior mass and within-model kernels exploring their supports, with aperiodicity, to obtain an ergodic chain. Include within-model updates targeting its conditional posterior, and use model occupation proportions after the initial transient to estimate posterior model probabilities. The formula includes the model prior probabilities, parameter prior densities, likelihoods, reverse model-selection probability, and reverse parameter-proposal density.
This direct-density formula is Metropolis–Hastings algorithm on a disjoint union of equal-dimensional spaces. If instead a move uses a deterministic bijection with auxiliary proposal densities and , useThe Jacobian determinant is one for identity matching, but equal model dimensions alone do not make a nonlinear map volume-preserving. For a direct proposal density the change of variables is already included in that density, so no additional Jacobian factor is inserted.
For the two Poisson models, use the shape-rate convention for the gamma distribution:If denotes scale instead, replace every occurrence of the rate below by . Introduce the inactive under model with the proper pseudo-prior , independent of . This pseudo-prior augmentation for model comparison does not change model 's marginal likelihood because the inactive density integrates to one. The two augmented targets on the same positive quadrant arewhereUse a symmetric cross-model proposal that flips the model label and leaves both parameters unchanged. The matching map is the identity, with unit Jacobian determinant, and the common prior factors cancel. Hence the model-switch acceptance probabilities areOnly the second observation's factor changes because is retained as its shared candidate mean. Evaluate the ratio on a logarithmic scale as for the first direction.
For within-model moves, Poisson-gamma conjugacy gives exact Gibbs sampling refreshes:The two draws are conditionally independent within either model. Choose with fixed positive probabilities between this block refresh and the cross-model proposal. Both moves preserve the augmented posterior; refreshing the inactive parameter maintains its correct distribution and supports mixing. The fraction of retained states labelled estimates .
An equivalent literal dimension-changing implementation deletes on a proposed move, and on a move draws an auxiliary and sets . The birth matching has dimensions and unit Jacobian determinant. Its proposal density cancels the new parameter's prior density, giving the same acceptance ratios above for symmetric selection of move directions. This provides suitable moves without storing an inactive parameter.
For an independent check of Poisson mean equality model comparison, the exact Bayes factor isIt follows by integrating the two gamma likelihood kernels; the common factorial terms cancel. With equal model priors, the exact posterior probability of is , which can also be used to check the RJ-MCMC occupation estimate.
Write for the standard normal distribution function. Integrating out the twenty independent past durations gives the threshold-censored normal likelihoodThe frequencies are those in part (a). For a future day, the conditional late-arrival probability is . Conditional independence of the five future durations gives .
Exactly three primitive random coordinates suffice. Draw from the same priors and one independent . Reject if ; otherwise return whether . Conditional on acceptance and the parameters, is uniform on an interval of length ; the true-answer subinterval has length . Reusing this same uniform value is therefore intentional, not an independence mistake.
Indeed the two output contributions at each parameter value areThese are exactly the contributions obtained by integrating the original twenty-five duration noises. Multiplication by the common prior density and normalization therefore give the same joint posterior distribution of . The revised program preserves the query and parameter posterior, but does not retain individual latent durations. This is uniform-interval encoding of conditioning and a binary query.
Here is an executable version, reusing the definitions from part (a). Logarithms avoid multiplying many small probabilities.
def normal_logcdf(z):
value = 0.5 * math.erfc(-z / math.sqrt(2.0))
return math.log(value) if value > 0.0 else -math.inf
def journey_loglik(mu, sigma):
return (sum(n * normal_logcdf((mu - c) / sigma)
for c, n in LATE.items())
+ sum(n * normal_logcdf((c - mu) / sigma)
for c, n in EARLY.items()))
def collapsed_trace(rng):
mu = rng.uniform(0.0, 60.0)
sigma = rng.uniform(1.0, 20.0)
log_likelihood = journey_loglik(mu, sigma)
# This uniform lies in (0, 1], avoiding log(0).
log_u = math.log(1.0 - rng.random())
if log_u >= log_likelihood:
return None
log_h = 5.0 * normal_logcdf((mu - 30.0) / sigma)
return log_u < log_likelihood + log_haccepted_average(collapsed_trace, n, rng) consequently has the same target as the original program. The ideal three-dimensional sample space is with product uniform probability measure, conditioned on the displayed acceptance event. Finite-precision normal tails can underflow to zero in this simple implementation; the mathematical equivalence concerns exact probabilities, and the numerical check in part (d) independently integrates the likelihood in the region carrying appreciable posterior mass.For any chosen proper prior density on with positive evidence, Bayes' theorem givesThe prior density comes from the first two random draws. The likelihood is the probability of satisfying all observed-label constraints after integrating the past duration noises. The factor is the probability of the five-day outcome conditional on the shared parameters. The denominator is the probability of acceptance, which converts the numerator's joint probability into the required conditional probability.
For the independent uniform priors in part (a), the constant cancels and both integrals reduce to , . A prior on the variance would require transforming the density: this chosen prior has density for conditional on . One must not silently replace it by a uniform prior on .
There is no unique numerical probability until the prior distribution is chosen. As a check for the stated uniform priors, independent Gaussian quadrature calculations with 256 and 512 nodes per coordinate agree at the shown precision:The prior-predictive probability of all observed labels is approximately , explaining the rejection cost. These numbers are illustrations of the explicit model, not additional observed data.
A subtle point is that the five future days are independent only conditional on . Integrating shared parameter uncertainty gives , not . The latter is about for these priors and understates the five-day probability. Jensen's inequality gives , while gives . For two future late-arrival indicator functions, their posterior covariance is . This is the posterior predictive repeated-success identity.
Posterior uncertainty and the five-day predictive probability for the explicitly chosen uniform priors. The contour is cropped to the parameter region carrying the visible mass; integration uses the full prior rectangle.
Details. 
