sbi icon indicating copy to clipboard operation
sbi copied to clipboard

ENH add h npe

Open tomMoral opened this issue 3 months ago • 1 comments

What does this implement/fix? Explain your changes

Implement hNPE, from this paper: https://arxiv.org/abs/2102.06477 This PR adds:

  • a hierachical_simulator decorator to wrap simulator and generate simulation with extra observations.
  • a HIerarchicalDensityEstimator which factorizes the posterior and chains two flows to estimate global and local parameters
  • a ``hierarchical_nnhelper to build a flow fromfactory`.

This PR also add an example of use case for this method.

Any relevant code examples, logs, error output, etc?

From the example: Without hierarchical observation, with a model $x = \theta_1 \theta_2$, we get ill defined posterior: image With 10 extra observation which shares the same $\theta_2$, we get: image

Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.

  • [x] I have read and understood the contribution guidelines
  • [x] I agree with re-licensing my contribution from AGPLv3 to Apache-2.0.
  • [ ] I have commented my code, particularly in hard-to-understand areas
  • [ ] I have added tests that prove my fix is effective or that my feature works
  • [ ] I have reported how long the new tests run and potentially marked them with pytest.mark.slow.
  • [ ] New and existing unit tests pass locally with my changes
  • [ ] I performed linting and formatting as described in the contribution guidelines
  • [x] I rebased on main (or there are no conflicts with main)

tomMoral avatar Mar 22 '24 01:03 tomMoral