Skip to content

posterior_based_potential should support IID x. #1804

Closed

Description

@manuelgloeckler

🚀 IID support for NPE with sample_with=vi/mcmc/importance

While its not possible to directly sample from NPE with IID observations one can evaluate the potential i.e. similar to score-based methods.

$$ p(\theta | x_1, ..., x_N) = (\prod_i p(\theta | x_i)/p(\theta) )p(\theta)$$

...

Support this in the potential

A error is currently raise here which should be resolved instead i.e. similar to how its done in likeihood based potentials.

This would make the sample_with support for NPE more useful (as its already possible to directly sample from the approximation directly).

Activity

  1. added
    enhancement
    on Mar 5, 2026
  2. satwiksps commented on Mar 10, 2026

    @satwiksps
    Collaborator

    Hi @manuelgloeckler
    If no one is currently working on this, I would love to pick it up.

    I would fix it in the same aprroach already used in VectorFieldBasedPotential.__call__:
    log p(θ|x₁,...,xₙ) = Σᵢ log p(θ|xᵢ) - (N-1) · log p(θ)

    PosteriorBasedPotential.set_x - Remove the NotImplementedError and pass x_is_iid through to BasePotential.set_x.
    PosteriorBasedPotential.__call__ - Add an IID branch that loops over each x_i, evaluates log p(θ|xᵢ) individually, sums them, and subtracts (N-1) · log p(θ).
    And also add a parametrised test comparing the IID potential log-prob against the analytically known linear Gaussian ground truth.

  3. manuelgloeckler commented on Mar 12, 2026

    @manuelgloeckler
    ContributorAuthor

    Hey @satwiksps ,

    no one is currently working on this as far as I know. So a contribution would be great :)

    The plan does look good. Note that this also requires a proper prior to be based to build_posterior or NeuralInference otherwise a ValueError should be raised. This also should avoid being affected by #1803 .

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions