We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 76110b7 commit f3606b5Copy full SHA for f3606b5
persim/persistent_entropy.py
@@ -1,3 +1,4 @@
1
+# -*- import
2
"""
3
4
The persistent entropy has been defined in [1]. A precursor of this definition was given in [2]
@@ -73,11 +74,14 @@ def persistent_entropy(
73
74
ps = []
75
for dgm in dgms:
76
l = dgm[:, 1] - dgm[:, 0]
- L = np.sum(l)
77
- p = l / L
78
- E = -np.sum(p * np.log(p))
79
- if normalize == True:
80
- E = E / np.log(len(l))
81
- ps.append(E)
+ if all(l > 0):
+ L = np.sum(l)
+ p = l / L
+ E = -np.sum(p * np.log(p))
+ if normalize == True:
82
+ E = E / np.log(len(l))
83
+ ps.append(E)
84
+ else:
85
+ raise Exception("A bar is born after dying")
86
87
return np.array(ps)
0 commit comments