Skip to content

Conversation

@renecotyfanboy
Copy link
Collaborator

Hi @Samreay
I am drafting a PR to implement multimodal resilient estimator for the posterior parameters.

In the same way as in arviz, I am trying to add HDI as a summarizer. Below are examples for the same chain marked as unimodal and multimodal

unimodal multimodal

I still should tinker a bit around to propose a proper implementation, as most of the current implementation is written by Codex.

The current way to use it is simply to mark a chain as multimodal when building it and to use the HDI stat to summarize each parameter :

chain_multimodal = Chain(
    samples=df,
    name="posterior-multimodal",
    statistics=SummaryStatistic.HDI,
    multimodal=True # Here
)

chain_unimodal = Chain(
    samples=df,
    name="posterior-unimodal",
    statistics=SummaryStatistic.HDI,
    multimodal=False # False by default 
)

@Samreay
Copy link
Owner

Samreay commented Nov 10, 2025

Sounds good to me! No initial thoughts on the implementation, tests, or doco updates apart from - when you're happy with the implementation - we should make sure usage.md is updated too, and potentially add a new example image in addition to docs/resources/stats.png like you've put above :)

@renecotyfanboy renecotyfanboy marked this pull request as ready for review November 25, 2025 17:01
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR implements multimodal HDI (Highest Density Interval) estimation for posterior parameters, similar to the functionality provided by ArviZ. The feature allows ChainConsumer to identify and visualize multiple disjoint density bands in multimodal distributions.

  • Adds HDI as a new summary statistic option
  • Implements multimodal interval detection using density thresholding
  • Updates visualization to display multiple intervals with appropriate formatting

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
src/chainconsumer/statistics.py Adds HDI enum value to SummaryStatistic
src/chainconsumer/chain.py Adds multimodal configuration field and validation logic
src/chainconsumer/analysis.py Implements HDI computation, interval detection, and multimodal bound conversion
src/chainconsumer/plotter.py Updates bar plotting to handle multiple intervals and format multimodal titles
tests/test_analysis.py Adds comprehensive tests for HDI functionality and ArviZ parity
tests/test_plotter.py Adds tests for multimodal visualization
tests/test_translators.py Updates MCMC configuration for sequential chain method
docs/examples/plot_7_multimodal_chains.py Adds example demonstrating multimodal chain usage
docs/examples/plot_5_emcee_arviz_numpyro.py Minor title correction

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

renecotyfanboy and others added 7 commits November 25, 2025 22:27
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 5 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@renecotyfanboy
Copy link
Collaborator Author

Hi @Samreay! I think this is good enough to be reviewed now. Sorry for the spam, I have been messing around with the new copilot reviews

Copy link
Owner

@Samreay Samreay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only one real comment! Oh and also I think usage.md should have the "Statistics" heading updated in text, even if we dont have an updated stats.png to add to the mix.

Copy link
Owner

@Samreay Samreay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great!

@Samreay
Copy link
Owner

Samreay commented Dec 11, 2025

All good on your end to merge, too? Feel free to merge, if so :)

@renecotyfanboy renecotyfanboy merged commit 0847cd8 into master Dec 11, 2025
14 checks passed
@renecotyfanboy
Copy link
Collaborator Author

Done! TY for your reviews @Samreay!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants