[go: up one dir, main page]

Skip to content

Commit

Permalink
only change negative values
Browse files Browse the repository at this point in the history
  • Loading branch information
mikedeltalima committed Dec 13, 2019
1 parent 8d52c7d commit 9363f60
Showing 1 changed file with 3 additions and 3 deletions.
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

0 comments on commit 9363f60

Please sign in to comment.