Support weighted statistics in `summary` diagnostics
Nobody has claimed this yet.
- 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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