Skip to content

Commit 6f72c5c

Browse files
committed
Correct np.cov references [fixes #145]
1 parent 5cdfb01 commit 6f72c5c

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

spectral/algorithms/algorithms.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1208,11 +1208,11 @@ def bdist_terms(a, b):
12081208
A 2-tuple of the linear and quadratic terms
12091209
'''
12101210
m = a.stats.mean - b.stats.mean
1211-
avgCov = (a.stats.cov + b.stats.cov) / 2
1211+
avg_cov = (a.stats.cov + b.stats.cov) / 2
12121212

1213-
lin_term = (1 / 8.) * np.dot(np.transpose(m), np.dot(np.inv(avgCov), m))
1213+
lin_term = (1 / 8.) * np.dot(np.transpose(m), np.dot(np.linalg.inv(avg_cov), m))
12141214

1215-
quad_term = 0.5 * (log_det(avgCov)
1215+
quad_term = 0.5 * (log_det(avg_cov)
12161216
- 0.5 * a.stats.log_det_cov
12171217
- 0.5 * b.stats.log_det_cov)
12181218

@@ -1317,7 +1317,7 @@ def unmix(data, members):
13171317
members = members.astype(float)
13181318
# Calculate the pseudo inverse
13191319
pi = np.dot(members, np.transpose(members))
1320-
pi = np.dot(np.inv(pi), members)
1320+
pi = np.dot(np.linalg.inv(pi), members)
13211321

13221322
(M, N, B) = data.shape
13231323
unmixed = np.zeros((M, N, members.shape[0]), float)

0 commit comments

Comments
 (0)