Skip to content

Comments

Allow multivariate parameters to be passed via pybamm.ParameterValues and define multivariate distributions in model space#862

Open
SarahRo wants to merge 17 commits intodevelopfrom
multivariate-parameters
Open

Allow multivariate parameters to be passed via pybamm.ParameterValues and define multivariate distributions in model space#862
SarahRo wants to merge 17 commits intodevelopfrom
multivariate-parameters

Conversation

@SarahRo
Copy link
Contributor

@SarahRo SarahRo commented Jan 6, 2026

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:

  • No style issues: $ pre-commit run or $ 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)
  • All tests pass: nox -s tests
  • The documentation builds: nox -s doctest
  • Code is commented for hard-to-understand areas
  • Tests added that prove fix is effective or that feature works

@codecov
Copy link

codecov bot commented Jan 6, 2026

Codecov Report

❌ Patch coverage is 99.31034% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 92.46%. Comparing base (4628a65) to head (3f779cb).
⚠️ Report is 28 commits behind head on develop.

Files with missing lines Patch % Lines
pybop/parameters/parameter.py 97.82% 1 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@SarahRo SarahRo marked this pull request as ready for review January 21, 2026 13:50
@SarahRo
Copy link
Contributor Author

SarahRo commented Feb 19, 2026

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.

@SarahRo SarahRo changed the title Multivariate parameters Allow multivariate parameters to be passed via pybamm.ParameterValues and define multivariate distributions in model space Feb 19, 2026
):
mean = transformation.to_search(self.properties["mean"])
covariance = transformation.convert_covariance_matrix(
self.properties["cov"], np.zeros(self._n_parameters)
Copy link
Member

Choose a reason for hiding this comment

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

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.

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.

Allow MultivariateParameters to be set within ParameterValues

2 participants