Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sprint15 add multiple likelihood posterior #151

Merged
merged 15 commits into from
Jan 30, 2023

Conversation

nabriis
Copy link
Collaborator

@nabriis nabriis commented Dec 3, 2022

Closes #123.

I left the MultipleLikelihoodPosterior in the joint distribution file because it uses both Distribution and JointDistribution, which makes theimports circular if not within the same file.

Edit: This has turned into a SingleVariablePosterior class. At the moment our joint distribution does not fully support multiple distributions for the same variable. This is because we enforce that each density must have a unique name. If we update this, the SingleVariablePosterior can work with multiple priors for the same parameter.

@nabriis nabriis self-assigned this Dec 3, 2022
@nabriis
Copy link
Collaborator Author

nabriis commented Dec 3, 2022

Hi @amal-ghamdi, I finished adding the new MultipleLikelihoodPosterior class. I also added a HowTo for defining Posteriors as I felt this was relevant now with this class.

Copy link
Contributor

@amal-ghamdi amal-ghamdi left a comment

Choose a reason for hiding this comment

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

Thank you @nabriis. The PR is really great! I have only few comments.

cuqi/distribution/__init__.py Show resolved Hide resolved
cuqi/distribution/_joint_distribution.py Show resolved Hide resolved
cuqi/distribution/_joint_distribution.py Outdated Show resolved Hide resolved
cuqi/distribution/_joint_distribution.py Outdated Show resolved Hide resolved
cuqi/distribution/_joint_distribution.py Outdated Show resolved Hide resolved
cuqi/distribution/_joint_distribution.py Outdated Show resolved Hide resolved
cuqi/distribution/_joint_distribution.py Outdated Show resolved Hide resolved
demos/howtos/posterior.py Outdated Show resolved Hide resolved
demos/tutorials/multiple_likelihoods.py Show resolved Hide resolved
demos/tutorials/multiple_likelihoods.py Show resolved Hide resolved
Copy link
Contributor

@amal-ghamdi amal-ghamdi left a comment

Choose a reason for hiding this comment

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

Thank you @nabriis for your updates and improving the robustness of this feature. I just added a minor documentation comment and I have one last thought about the class name. SingleVariablePosterior gives a sense that it is more of a special case of the posterior, not a generalization. But I leave it to you and @jakobsj if you think we should update the name or keep it for now.

Looks great to me!

cuqi/distribution/_joint_distribution.py Outdated Show resolved Hide resolved
cuqi/distribution/_joint_distribution.py Show resolved Hide resolved
@nabriis nabriis requested a review from jakobsj December 15, 2022 13:46
Copy link
Contributor

@jakobsj jakobsj left a comment

Choose a reason for hiding this comment

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

Thank you for adding this great new feature. After discussing it (again) today, I am happy to see it merged, with a few minor changes and as discussed renaming back to MultipleLikelihoodPosterior.

We discussed this PR as step toward a new zoo of Posterior classes with specific purpose and behaviors, probably organized into a subclass structure with a generic (Joint?)Posterior at the top, from which branches of dedicated subclasses could be formed, such MultipleLikelihoodPosterior and from that perhaps the existing Posterior as a special case of single likelihood. This would likely involve a JointPosterior and we should decide on systematic naming conventions. Please before merging this PR could you create one or more issues (likely not labelled ready) to capture this idea.

cuqi/distribution/_joint_distribution.py Outdated Show resolved Hide resolved
cuqi/distribution/_joint_distribution.py Outdated Show resolved Hide resolved
demos/howtos/posterior.py Outdated Show resolved Hide resolved
cuqi/distribution/_joint_distribution.py Outdated Show resolved Hide resolved
@nabriis nabriis requested a review from jakobsj January 27, 2023 21:02
@nabriis
Copy link
Collaborator Author

nabriis commented Jan 27, 2023

Hi @jakobsj thanks for the comments!

Copy link
Contributor

@jakobsj jakobsj left a comment

Choose a reason for hiding this comment

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

Looks good!

@nabriis nabriis merged commit 6286d50 into main Jan 30, 2023
@nabriis nabriis deleted the sprint15_add_MultipleLikelihoodPosterior branch January 30, 2023 16:07
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.

Eliminate the need for using _as_stacked in joint distributions
3 participants