Allow multivariate parameters to be passed via pybamm.ParameterValues and define multivariate distributions in model space#862
Open
Allow multivariate parameters to be passed via pybamm.ParameterValues and define multivariate distributions in model space#862
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #862 +/- ##
===========================================
+ Coverage 89.41% 92.46% +3.04%
===========================================
Files 63 71 +8
Lines 4857 5495 +638
===========================================
+ Hits 4343 5081 +738
+ Misses 514 414 -100 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Contributor
Author
|
Warning The order of multivariate parameters is currently not verified inside pybop.Parameters(). They are assumed to be passed in order of the position property of the pybop.MarginalDistribution. |
| ): | ||
| mean = transformation.to_search(self.properties["mean"]) | ||
| covariance = transformation.convert_covariance_matrix( | ||
| self.properties["cov"], np.zeros(self._n_parameters) |
Member
There was a problem hiding this comment.
Suggested change
| self.properties["cov"], np.zeros(self._n_parameters) | |
| self.properties["cov"], mean |
As far as I understand, the Jacobian should be evaluated at the transformed mean for this conversion.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The changes in the PR allow multivariate parameters to be passed via pybamm.ParameterValues. Moreover, multivariate distributions are now defined in the model space instead of the search space.
Introduces a MarginalDistribution class (subclass of Distribution) that is constructed from a BaseMultivariateDistribution. This is achieved by adding a method called 'marginal' to the multivariate distributions that returns the marginal distribution. The pybop.MarginalDistribution retains the original multivariate distribution in the parent_distribution attribute.
Introduces a MultivariateLogNormal class in order to define the distribution in the model space for the ep-bolfi example.
The MultivariateParameters class is removed. Instead, a check_multivariate method is added to pybop.Parameters() that checks whether a MarginalDistribution is present and if so whether all parameters have a MarginalDistribution with the same parent_distribution. This method is called in the constructor, the set method and the add method. The call to the method can be disabled in the add and set method by setting the parameter check_multivariate to false. This is, for example, used in the constructor in order to only call the method once all parameters have been added.
Fixes #856
Type of change
Please add a line in the relevant section of CHANGELOG.md to document the change (include PR #).
Important checks:
Please confirm the following before marking the PR as ready for review:
$ pre-commit runor$ nox -s pre-commit(see CONTRIBUTING.md for how to set this up to run automatically when committing locally, in just two lines of code)nox -s testsnox -s doctest