mrzv / dionysus

Library for computing persistent homology
http://mrzv.org/software/dionysus2
Other
147 stars 31 forks source link

How to interpret homology_persistence output #8

Closed grjd closed 7 years ago

grjd commented 7 years ago

The output of homology_persistence is not quite self explanatory. It would be nice to have a mre informative message for example, stating the birth and death of the homology class. In my example, I use a filtration starting with 4 disconnected nodes, ending up forming a tetrahedron. What the output means?

simplices = [([0],1), ([1],2),([2],3),([3],4),([0,1],5),([2,3],6), ([1,2],7),([1,3],8), ([0,2],9), ([0,3],10)]
f =d.Filtration()
m = d.homology_persistence(f)
for c,i in enumerate(m):
   print(c,i)

(0, ) (1, ) (2, ) (3, ) (4, 10 + 11) (5, 12 + 13) (6, 11 + 12) (7, ) (8, ) (9, )

mrzv commented 7 years ago

You are iterating over the internal representation of the reduced boundary matrix (which is giving you cycles that are killed by the simplices, or empty cycles if a class if born). You probably want to get a persistence diagram. More details are at http://mrzv.org/software/dionysus2/tutorial/basics.html

sauln commented 6 years ago

Hi @mrzv, I'm also having trouble interpreting this output. In the basics page you link, an example is

 >>> m = d.homology_persistence(f)
 >>> for i,c in enumerate(m):
 ...     print(i, c)
 0
 1
 2 1*0 + 1*1
 3
 4 1*1 + 1*3
 5

Could you please explain what each of the numbers in the output mean:

i a*b + c*d

I am looking to compute representative cycles and am hoping this information will give it to me.

Thank you.

mrzv commented 6 years ago

m is the reduced boundary matrix. If we refer to the simplices in the filtration order as s_0, s_1, s_2, ... then

i a*b + c*d

means that addition of simplex s_i sent (previously non-zero) cycle a*s_b + c*s_d to zero.

Does that make sense?

mrzv commented 6 years ago

I should add that depending on which optimization you use, the cycles might be pruned (i.e., missing some simplices). This shouldn't happen by default, but it will happen, if you pass, for example, method = "column_no_negative".