From 77cd751b729d6b68a49ae99e86cff481220ec367 Mon Sep 17 00:00:00 2001 From: Manu Date: Mon, 7 Mar 2022 09:55:17 +0100 Subject: minor changes in entropy --- src/python/gudhi/representations/vector_methods.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'src/python/gudhi/representations') 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])) -- cgit v1.2.3