AI Wiki中文/EN

Credible intervals

可信区间

Interpret posterior mass and compute exact quantile brackets for a Beta example.

On this pageIntuitionMathematics & methodImplementationLimitationsExercisesResearch connections

Put probability on parameter uncertainty under a model

A binary process succeeds three times and fails once. What success rates remain plausible? A Bayesian analysis combines a likelihood for these observations with a prior over the rate, producing a posterior distribution. A credible interval summarizes a chosen amount of that posterior probability.

The interval is conditional on the observed data and the model. It is not a statement that the next binary observation will lie between two fractional endpoints. It is also not a guarantee against a misspecified likelihood or an unsuitable prior.

Read Bayes’ theorem, Beta distributions and conjugate priors first.

State the posterior probability being summarized

A credible set C with posterior probability 1−α satisfies:

Pr⁡(θ∈C∣D)=∫Cp(θ∣D) dθ=1−α.\Pr(\theta\in C\mid D)=\int_C p(\theta\mid D)\,d\theta=1-\alpha.

There can be many such sets. An equal-tailed interval leaves α/2 probability in each tail; a highest-posterior-density region instead selects high-density values until the required mass is reached. They need not coincide, and a highest-density region may have disconnected pieces for a multimodal posterior. Stanford’s STATS 200 Lecture 20, §20.2 defines credible intervals and the equal-tail construction.

Derive a posterior with a polynomial CDF

Assume independent Bernoulli observations with one constant success probability θ. A uniform Beta(1,1) prior, combined with three successes and one failure, gives Beta(4,2). The likelihood contributes θ³(1−θ), and normalization yields:

p(θ∣D)=20θ3(1−θ),F(θ)=5θ4−4θ5,0≤θ≤1.p(\theta\mid D)=20\theta^3(1-\theta),\qquad F(\theta)=5\theta^4-4\theta^5,\qquad 0\le\theta\le1.

Integrating the density gives the displayed cumulative distribution function, with F(0)=0 and F(1)=1. Its mean is 4/(4+2)=2/3. The NIST Beta-distribution reference supplies the general family; the polynomial expression here is derived for this particular posterior.

For a 90% equal-tailed interval, choose the 5th and 95th posterior percentiles:

C0.90=[q0.05,q0.95],F(q0.05)=0.05,F(q0.95)=0.95.C_{0.90}=[q_{0.05},q_{0.95}],\qquad F(q_{0.05})=0.05,\quad F(q_{0.95})=0.95.

Subtracting CDF values gives posterior mass 0.90. The interval is generally asymmetric around the mean because the posterior is skewed. At θ=1/2, F=3/16, so the posterior probability of θ being greater than 1/2 is 13/16. That is a separate posterior question, not the interval’s nominal probability.

Credibility and repeated-sampling coverage differ

A frequentist confidence procedure targets coverage across hypothetical repeated datasets for a fixed parameter. A Bayesian credible interval assigns posterior mass conditional on this dataset and the chosen model. Some procedures have both useful properties, but one does not follow merely from the shared percentage label. Compare with confidence intervals.

Bracket quantiles using exact CDF evaluations

Run the complete Python 3.12 standard-library program. It uses exact fractions to bisect the monotone Beta(4,2) CDF. The helper accepts rational probabilities and 1–80 bisections. Each bracket contains the target quantile; no numerical Beta special-function library is needed for this polynomial case.

from fractions import Fraction as F


def cdf42(x):
    if type(x) not in (int,F) or not 0 <= x <= 1:
        raise ValueError('rational x in [0,1] required')
    x=F(x)
    return 5*x**4-4*x**5


def quantile_bracket(probability,steps=60):
    if type(probability) not in (int,F) or not 0 <= probability <= 1:
        raise ValueError('rational probability in [0,1] required')
    if type(steps) is not int or not 1 <= steps <= 80:
        raise ValueError('integer bisection count in [1,80] required')
    p=F(probability)
    if p in (0,1):return p,p
    lo,hi=F(0),F(1)
    for _ in range(steps):
        middle=(lo+hi)/2
        if cdf42(middle)<p:lo=middle
        else:hi=middle
    return lo,hi


if __name__ == '__main__':
    lower=quantile_bracket(F(1,20));upper=quantile_bracket(F(19,20))
    left,right=lower[0],upper[1]
    mass=cdf42(right)-cdf42(left)
    assert mass>=F(9,10)
    print('posterior: Beta(4,2)')
    print('90% equal-tail endpoints, approximately:',round(float(left),6),round(float(right),6))
    print('unrounded bracket mass at least 0.9:',mass>=F(9,10))
    print('P(theta > 1/2 | data):',1-cdf42(F(1,2)))
    print('posterior mean:',F(2,3))

Output:

posterior: Beta(4,2)
90% equal-tail endpoints, approximately: 0.342592 0.92356
unrounded bracket mass at least 0.9: True
P(theta > 1/2 | data): 13/16
posterior mean: 2/3

The lower endpoint uses the lower edge of its quantile bracket, and the upper endpoint uses the upper edge. Their exact posterior mass is at least 0.90 with a tiny excess due to finite bracketing. Each unrounded bracket is at most 2⁻⁶⁰ wide. Displayed six-decimal endpoints are approximations and are not the exact bracket endpoints used for the mass check.

Bisection takes O(m) CDF evaluations for m iterations, with a constant number of live rational variables and increasing bit sizes. General posteriors may need numerical integration, specialized quantile functions or posterior simulation; this helper is intentionally limited to Beta(4,2).

The posterior inherits the prior and likelihood

With only four observations, a different prior can materially change the interval. Nonstationarity or dependent trials can invalidate the simple Bernoulli likelihood. More arithmetic precision cannot repair those modeling choices.

A parameter interval differs from a posterior predictive distribution. For one next Bernoulli observation, the predictive success probability is the posterior mean 2/3, while the observation itself is either zero or one. For multiple future observations, uncertainty about θ affects the joint predictive distribution.

When intervals are estimated from MCMC draws, simulation error and chain dependence add uncertainty to the estimated endpoints. A narrow reported interval does not prove the chain explored every relevant posterior mode. Also state the parameterization when using highest-density regions; density-based summaries can change under nonlinear transformations.

Name the random quantity and the conditioning

  1. What posterior follows from a uniform rate prior and three successes plus one failure?

Answer 1: Beta(4,2), under the independent constant-rate Bernoulli likelihood.

  1. Why are the 5th and 95th percentiles a 90% equal-tailed interval?

Answer 2: They leave 5% posterior probability below and 5% above, so 90% lies between them for this continuous posterior.

  1. What is the posterior probability that θ exceeds 1/2?

Answer 3: 1−F(1/2)=1−3/16=13/16. This uses the whole posterior, not a confidence-level label.

  1. Is the next observed outcome predicted to fall inside the rate’s fractional credible interval?

Answer 4: No. The next outcome is binary. Its posterior predictive success probability is 2/3; the interval summarizes the unknown rate.

Report the model alongside the interval

The Stanford notes provide the interpretation and quantile construction, and NIST describes the Beta family. The exact CDF and bracketing experiment make the posterior-mass statement directly checkable.

For a project, compare two explicitly justified priors on the same four observations and report both posterior intervals and predictive probabilities. Then increase the data size under a fixed likelihood to see when the prior’s influence diminishes, without claiming that it disappears for every dataset or model.

Make a prediction, then check

What does this 90% credible interval summarize?

Choose one answer

Learning objectives

  • Interpret credible intervals conditional on a prior and likelihood.
  • Verify posterior quantiles and distinguish predictive uncertainty.

Prerequisites & connections

Explore related knowledge →

References

  1. STATS 200 Lecture 20 — Bayesian analysis
    Stanford University, STATS 200 course notes · 2016
  2. NIST/SEMATECH e-Handbook — Beta Distribution
    NIST and SEMATECH

Version1 · Editorial status: Recorded technical checks completed

View technical check record (AI)

Codex · 2026-09-06 · Codex single-agent authored technical review: primary-source locations, explicit assumptions, derivations, exact/literal and numerical checks, and bilingual review; not independent human or second-agent peer review.

  • Single-agent authored technical review: primary-source locations, explicit domains and assumptions, derivations, literal/exact probability or numerical reference cases, bilingual examples and exercises. Not independent human or second-agent review.
  • Four focused tests passed on CPython3.12.4; NumPy1.26.4 actually executed for the Fourier chapter. Exact rational probability/stencil checks are distinguished from floating-point calculations and observed Monte Carlo output. Both languages render three equations, six anchors and four answers; final repository checks recorded separately.
  • Promoted the full prose, equations, code and exercises. Tests read formal MDX only; removed temporary fallbacks/draft skips and updated review assertion to checked. Algorithm and independent references are unchanged; final record binds both locale hashes.
  • Publication navigation points published topics to complete articles and removes corresponding pending wording, retaining directory entries for unwritten targets. Principles, equations, programs and exercises are unchanged; final article SHA values rebound.

Source locations checked:

Related topics

No matches. Try a synonym or acronym.

0 results shown

Wrap the whole query in double quotes for a phrase match.