Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
only change negative values
  • Loading branch information
mikedeltalima committed Dec 13, 2019
commit 9363f608a14fe596b98b5dd8e26d62811871ba0c
6 changes: 3 additions & 3 deletions src/qinfer/distributions.py
Original file line number Diff line number Diff line change
Expand Up @@ -394,14 +394,14 @@ def particle_covariance_mtx(cls, weights, locations):
# is produced, we should warn the caller of this.
assert np.all(np.isfinite(cov))
vals, vecs = la.eig(cov)
small_vals = abs(vals) < 1e-12
vals[small_vals] = 0
small_negative_vals = (vals < 0) & (vals > -1e-12)
vals[small_negative_vals] = 0
if not np.all(vals >= 0):
warnings.warn(
'Numerical error in covariance estimation causing positive semidefinite violation.',
ApproximationWarning
)
if np.any(small_vals):
if np.any(small_negative_vals):
return (vecs * vals) @ vecs.T.conj()
return cov

Expand Down