pyro-ppl / pyro-ppl/numpyro

Support weighted statistics in `summary` diagnostics

Open
#810 6 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement good first issue
Dominant language
Python
Stars
2.8k
Forks
315
Avg merge
3d 9h
Merged PRs (30d)
27

Description

Currently, summary returns ordinary statistics mean/var/quantiles/n_eff for MCMC samples. It would be nice to extend that utility to calculate weighted statistics. This would be useful for important sampling or nested sampling.

Proposal implementation: add a keyword log_weights (or weights) to summary:

def summary(samples, prob=0.90, group_by_chain=True, log_weights=None):
    ...

If log_weights is not None, then we return weighted mean, weighted var, weighted quantiles (instead of hpdi?), effective sample size for weighted samples, and skip r_hat.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The target entry point is numpyro/diagnostics.py around summary (line 219); first read its current statistic and shape handling and the linked effective sample size definition. Verify the weighted branch's mean, variance, quantiles, ESS, and omitted r_hat, including its weight input convention, against the existing diagnostics tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
numpy, python
Domain
data
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.