summaryrefslogtreecommitdiff
path: root/src/python/gudhi/representations
diff options
context:
space:
mode:
Diffstat (limited to 'src/python/gudhi/representations')
-rw-r--r--src/python/gudhi/representations/vector_methods.py6
1 files changed, 2 insertions, 4 deletions
diff --git a/src/python/gudhi/representations/vector_methods.py b/src/python/gudhi/representations/vector_methods.py
index 57ca5999..7d6a7f27 100644
--- a/src/python/gudhi/representations/vector_methods.py
+++ b/src/python/gudhi/representations/vector_methods.py
@@ -518,8 +518,7 @@ class Entropy(BaseEstimator, TransformerMixin):
new_diagram = np.empty(shape = [0, 2])
p = new_diagram[:,1]
- L = sum(p)
- p = p/L
+ p = p/np.sum(p)
if self.mode == "scalar":
ent = -np.dot(p, np.log(p))
Xfit.append(np.array([[ent]]))
@@ -529,8 +528,7 @@ class Entropy(BaseEstimator, TransformerMixin):
[px,py] = orig_diagram[j,:2]
min_idx = np.clip(np.ceil((px - self.sample_range[0]) / step_x).astype(int), 0, self.resolution)
max_idx = np.clip(np.ceil((py - self.sample_range[0]) / step_x).astype(int), 0, self.resolution)
- for k in range(min_idx, max_idx):
- ent[k] += (-1) * p[j] * np.log(p[j])
+ ent[min_idx:max_idx]-=p[j]*np.log(p[j])
if self.normalized:
ent = ent / np.linalg.norm(ent, ord=1)
Xfit.append(np.reshape(ent,[1,-1]))