Skip to content

Ensemble potential() and joint map() mix unnormalized component potentials #2135

Open

Description

@janfb

EnsemblePotential.__call__ (sbi/inference/posteriors/ensemble_posterior.py) returns the weighted log-sum-exp of its components' potentials. A mixture of posteriors needs normalized component densities. NLE and NRE potentials are unnormalized, and so are NPE potentials with several iid observations (issue #2125). Each component then enters the mixture with its own normalization constant, so the ensemble's potential() and joint map() disagree with sample(), which draws each component in proportion to its weight.

Example in plain math: components q₁(θ|x) = N(x, 1) and q₂(θ|x) = N(5x + 5, 1), prior N(0, 10²), iid observations 0 and 1, weights 1:3. The mode of the weighted iid potentials is 0.50; the mode of the mixture of the normalized posteriors is 7.54.

Fix direction: normalize each component before mixing (the importance posterior already estimates log normalization constants), or raise when a component is unnormalized. sample() and map(individually=True) are correct and should stay as they are.

Activity

  1. added
    bug
    on Nov 1, 2026
  2. self-assigned this
    on Nov 1, 2026
  3. added
    posteriors
    on Nov 1, 2026
  4. janfb commented on Nov 10, 2026

    @janfb
    ContributorAuthor

    The same mix also happens in two places the issue does not list yet:

    • log_prob(): MCMC and rejection posteriors return their unnormalized potential there, so an ensemble of NLE or NRE posteriors mixes unnormalized values in log_prob() too.
    • Vector field posteriors with several observations: their log prob multiplies the per-observation posteriors and divides by the prior n - 1 times, so it is known only up to a constant. An ensemble of FMPE posteriors mixes these values in log_prob() on main, and in potential() once PR fix: count iid trials by the observation shape, and combine iid observations in the sampling posteriors #2140 lets it take several observations.

    Importance posteriors normalize their log_prob() per x, so their ensembles are fine there. So the fix should cover log_prob() as well, and check per component whether its values are normalized.

  5. janfb commented on Nov 18, 2026

    @janfb
    ContributorAuthor

    Once PR #2140 is merged, the ensemble raises in potential(), log_prob() and the joint map() for several observations when a component has an NPE or vector field potential. In log_prob(), this also blocks importance and single-x VI components, although their log_prob() is normalized per x and their mixture would be correct. The per-component check above should lift that restriction as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugposteriors

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions