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

Catch positive definite error #24

Merged
merged 2 commits into from Aug 2, 2022
Merged

Catch positive definite error #24

merged 2 commits into from Aug 2, 2022

Conversation

OriolAbril
Copy link
Member

Even though the docstring from https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.multivariate_normal.html says

Symmetric positive (semi)definite covariance matrix of the distribution.

It also accepts matrices whose determinant is close to 0 but negative, generally due to numerical issues. It doesn't expect users to solve those numerical issues themselves before passing the covariance matrix to the multivariate_normal class or methods. This adds a try/except to catch the error related to this issue and checks if adding an identity matrix with 1e-10 to the provided covariance matrix solves the issue.

cc @symeneses

@codecov
Copy link

codecov bot commented Aug 2, 2022

Codecov Report

Merging #24 (3d7a512) into main (72f0e42) will decrease coverage by 0.56%.
The diff coverage is 42.85%.

@@            Coverage Diff             @@
##             main      #24      +/-   ##
==========================================
- Coverage   91.83%   91.26%   -0.57%     
==========================================
  Files           6        6              
  Lines         612      618       +6     
==========================================
+ Hits          562      564       +2     
- Misses         50       54       +4     
Impacted Files Coverage Δ
src/xarray_einstats/stats.py 89.47% <42.85%> (-1.52%) ⬇️

Help us with your feedback. Take ten seconds to tell us how you rate us.

@OriolAbril OriolAbril merged commit 93bfdc0 into main Aug 2, 2022
@OriolAbril OriolAbril deleted the catch_cov_num_error branch August 2, 2022 14:19
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.

None yet

1 participant