What a posterior and a 90% credible region promise
Sandbox Physics ·
A posterior is the probability distribution of an unknown quantity after the data are in, and a 90% credible region is a part of it that holds 90% of that probability. The promise attached to the region is an average one: if true values are drawn from the prior and data are simulated from the model, the region contains the true value in 90% of cases. At one fixed true value the fraction can be higher or lower.
This chapter assumes probability densities and the normal distribution. The Lab on likelihoods and priors in cosmology builds the prior and likelihood picture with sliders; here we turn it into equations. The aims are to compute a posterior by hand and on a grid, derive the coverage promise, and see where it fails for a fixed source.
Prior, likelihood and posterior for one number
Let the unknown be a single number θ. Before measuring, our knowledge is the prior density p(θ). A measurement produces data y, and the model states how likely each data set is for each value of θ: this is the likelihood p(y∣θ), read as a function of θ with y fixed. Bayes' theorem combines them:
p(θ∣y)=p(y)p(y∣θ)p(θ),p(y)=∫p(y∣θ)p(θ)dθ.
The denominator p(y), called the evidence, does not depend on θ. It only makes the posterior integrate to one.
Take a concrete model. The prior is standard normal, θ∼N(0,1). We make n independent measurements yi=θ+ei, each with Gaussian noise of known standard deviation s. Then
lnp(θ∣y)=−2θ2−i=1∑n2s2(yi−θ)2+const.
The right side is quadratic in θ, so the posterior is normal. Collect the θ2 and θ terms and complete the square:
p(θ∣y)=N(μ,v),v=1+n/s21,μ=s2vi=1∑nyi.
The posterior variance v is smaller than both the prior variance 1 and the single-measurement variance s2. The mean μ is the data average pulled toward the prior mean zero; this pull is called shrinkage.
A worked example
Use n=4 and s=1, with measurements 1.3, 0.2, 1.1 and 0.6. Their sum is 3.2. The posterior variance is v=1/5=0.2, so the posterior standard deviation is 0.2≃0.447. The mean is μ=0.2×3.2=0.64, smaller than the data average 0.8 because of shrinkage.
For a normal posterior the central 90% interval runs 1.645 standard deviations either side of the mean, where 1.645 is the point with 95% of a standard normal below it:
μ±1.645v=0.64±0.736⇒[−0.096,1.376].
For a symmetric single-peaked posterior this central interval is also the highest-density region: the shortest interval holding 90% of the probability.
The same posterior on a grid
Most posteriors have no closed form. The Lab's exact reference therefore computes the posterior on a grid, and the same steps work here.
Lay down cells of width 0.01 from −3 to 3 and take each cell centre as a candidate θj.
Evaluate the log prior plus log likelihood at each centre. Subtract the largest value before exponentiating so that no number underflows.
Divide by the sum so the cell probabilities Pj add to one.
Sort cells from highest to lowest Pj and add them up until the total reaches 0.9. Those cells form the 90% highest-density region.
Doing this gives a grid mean of 0.640 and standard deviation 0.447. The region takes 148 cells holding 0.902 of the probability and spans [−0.10,1.38]. The small excess over 0.9 and the shift at the edges come from whole cells being added at once. In the Lab, the same recipe runs on a two-dimensional grid over frequency and damping time, refined around the peak so the cells stay much smaller than the posterior width.
Why the region catches the truth nine times in ten
Call the region R(y) and suppose it holds posterior probability 0.9 for every data set. Now imagine many repeated experiments: each draws a true value from the prior, then data from the likelihood. The fraction of experiments in which the truth lands inside the region is
Pr[θ∈R(y)]=∫∫p(θ)p(y∣θ)1[θ∈R(y)]dθdy.
Bayes' theorem lets us rewrite p(θ)p(y∣θ) as p(y)p(θ∣y). The inner integral over θ then becomes the posterior probability of the region, which is 0.9 for every y:
Two assumptions carried this result. The true values were drawn from the same prior the posterior used, and the data came from the same likelihood. Hermans and colleagues call the fraction on the left the expected coverage and use it as their main test of approximate posteriors. Hermans and colleagues, 2022, Definition 2.1 Talts and colleagues start from the same identity: averaged over the data, the posterior returns the prior. Talts and colleagues, 2018, Section 2
Coverage at one fixed true value
Hold the true value fixed and repeat only the noise. In the example, μ−θ is then normal with mean −0.2θ and standard deviation 0.4, because shrinkage pulls every estimate toward zero by a fifth. The 90% interval has half-width 0.736, so its coverage at fixed θ is
C(θ)=Φ(0.40.736+0.2θ)−Φ(0.4−0.736+0.2θ),
where Φ is the standard normal cumulative distribution.
Table 2.1 Coverage of the exact 90% interval at a fixed true value.
True value
Coverage at that value
θ=0
0.934
θ=1
0.900
θ=2
0.797
θ=3
0.632
Near the prior centre the exact interval over-covers; far out it under-covers. Weighting these values by the standard normal prior and integrating gives back exactly 0.900. An exact posterior is calibrated on average, not at every source.
The Lab shows the same effect in two dimensions. Its faint, short ringdown sits near the edge of the prior box. Over 400 synthetic records at that fixed source, the exact grid posterior's 90% region caught the source in 0.860 of them, with a 95% interval of 0.823 to 0.891 on that fraction.
Predict, then watch: with the trained conditions, where should both running coverage curves settle after a minute? Explain the size of their early wobble from the number of records.
Change one condition: choose the faint, short ringdown. Before the curves settle, predict whether the exact posterior's coverage will sit above or below 0.9, using Table 2.1 as a guide.
Compare: drag the white marker in the parameter plane toward the centre of the prior box and then toward a corner. Watch the exact 90% contour change shape near the box edge.
Exercises
With the same prior and s=1, how many measurements are needed to bring the posterior standard deviation below 0.2?
A colleague reports a 90% interval and says the true value has a 90% chance of being inside for this particular source. Under what condition is that a fair reading?
In the grid recipe, why must the cells be much narrower than the posterior width? What happens to the 90% region if they are not?
AnswersShow the answer
The variance is v=1/(1+n). We need v<0.04, so 1+n>25 and n≥25. The posterior standard deviation then falls to 1/26≃0.196.
The statement is a probability over the posterior, given these data. It is fair if the prior and likelihood describe how sources and data are really produced. The frequency statement that follows from it is an average over sources drawn from the prior. At one fixed source the frequency can differ, as Table 2.1 shows.
The region is built from whole cells. Wide cells add probability in large steps, so the region overshoots 0.9 and its edges land on cell boundaries. A narrow posterior can also fall between two cell centres and be badly misrepresented. In the worked example cells of 0.01 are about one forty-fifth of the posterior width, so the overshoot is only 0.002.