user_guide:tutorials:persistent_homology

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
user_guide:tutorials:persistent_homology [2019/01/29 21:46] – external edit 127.0.0.1user_guide:tutorials:persistent_homology [2019/02/04 22:55] (current) – external edit 127.0.0.1
Line 1: Line 1:
-====== Persistent Homology Tutorial ===== +{{page>.:latest:@FILEID@}}
-Persistent homology is a construct from algebraic topology that formalizes the effect that changing a topological space in a certain way has on its homologyIt attempts to overcome the lack of robustness homology showschanging the space of interest just a little can result in a drastic change in homology. The approach to this is to consider the homology of the space at different "resolutions", so to say -- for example by approximating it by a sequence of chain complexes that grow more and more complicated and accurate. One can then try to distinguish prominent topological features in arbitrary dimensions from the irrelevant ones by discarding the features that are only present at a few resolutions.+
  
-[[http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.10.5064|This paper]] introduces the concept and presents the algorithms. See e.g. [[http://www.ams.org/journals/bull/2009-46-02/S0273-0979-09-01249-X/|this article]] for a deeper survey of the topic. 
- 
-To use the function, one has to switch to the ''topaz'' application. See this [[..:topaz_tutorial|tutorial]] for a general introduction to ''topaz''. 
- 
-<code> 
-polytope > application 'topaz'; 
-</code> 
- 
-===== Filtrations ===== 
- 
-The objects of study are filtrations of chain complexes with finitely many frames. The data structure is templated by the type of matrix used for the description of the boundary maps. 
- 
-====From Hasse diagrams==== 
-A filtration can be initialized by passing the Hasse diagram of the last frame of the filtration and an array containing the degree of each cell, indexed in the same order as the node indexing in the Hasse diagram (without the empty set and the dummy node with index 0, thus shifted by one). Consider this small three-frame example filtration: 
- 
-{{ user_guide:small_filtration.png?800 |}} 
- 
-You can construct it in ''polymake'' like this: 
-<code> 
-topaz > $S = new SimplicialComplex(FACETS=>[[0,1],[0,2],[1,2],[3]]); 
- 
-topaz > $HD = $S->HASSE_DIAGRAM;              # Hasse diagram of the last frame 
-topaz > print rows_numbered($HD->FACES);      # check indexing 
-0:-1 
-1:0 1 
-2:0 2 
-3:1 2 
-4:3 
-5:0 
-6:1 
-7:2 
-8: 
-topaz > $a = new Array<Int>(1,2,1,2,0,0,1);   # assign degrees to the simplices ([0,1] gets degree 1, [0,2] degree 2 etc) 
- 
-topaz > $F = new Filtration<SparseMatrix<Rational>>($HD,$a); 
-</code> 
- 
-You can print the boundary matrix for each frame and dimension: 
-<code> 
-topaz > print $F->boundary_matrix(1,1);     # print dimension 1 matrix of frame 1 
-1 -1 0 
-0 1 -1 
-</code> 
-To find out which rows correspond to which cells, you can print the cells of the filtration. They will be output as an array of 3-tuples, each representing one cell with degree, dimension and boundary matrix index. 
-<code> 
-topaz > print $F->cells; 
-(0,0,1) (0,0,2) (1,0,3) (1,1,0) (1,1,2) (2,0,0) (2,1,1) 
-</code> 
- 
-====From boundary matrices==== 
-It is also possible to construct a filtration by passing such an array of cells, together with an array of matrices to be used as boundary matrices. To construct the same filtration as above: 
-<code> 
-topaz > $C = new Array<Cell>(7); 
-topaz > $C->[0] = new Cell(0,0,1); 
-        $C->[1] = new Cell(0,0,2); 
-        $C->[2] = new Cell(1,0,3); 
-        $C->[3] = new Cell(1,1,0); 
-        $C->[4] = new Cell(1,1,2); 
-        $C->[5] = new Cell(2,0,0); 
-        $C->[6] = new Cell(2,1,1); 
-         
-topaz > $bd = new Array<SparseMatrix<Rational>>(3); 
-topaz > $bd->[0] = new SparseMatrix<Rational>([1],[1],[1],[1]); 
-        $bd->[1] = new SparseMatrix<Rational>([0,1,-1,0],[0,1,0,-1],[0,0,1,-1]); 
-        $bd->[2] = new SparseMatrix<Rational>(); 
- 
-topaz > $F = new Filtration<SparseMatrix<Rational>>($C,$bd); 
-</code> 
- 
- 
- 
-====Vietoris-Rips filtration==== 
-It is also possible to compute the Vietoris-Rips-filtration of a point set given a metric. The input consists of the distance matrix of the point set (that is, the matrix whose i,j-entry is the distance between points i and j), an array containing the filtration degrees of the points, the increase in ball size per frame, and an upper bound to the dimension (so one can compute lower-dimensional skeletons and save space). The following computes the four-skeleton of the VR-filtration of six random points in 5-space using the euclidean metric: 
- 
-<code> 
-topaz > $S = polytope::rand_sphere(5,6)->VERTICES; 
-topaz > $P = $S->minor(All,sequence(1,5));     # dehomogenize 
- 
-topaz > sub dist($){                          # define euclidean metric 
-topaz(2) > my $v = $_[0] - $_[1]; 
-topaz(3) > return sqrt(new Float($v*$v));}; 
- 
-topaz > $D = distance_matrix($P,\&dist);       # conmpute distance matrix of the point set 
- 
-topaz > $a = new Array<Int>(6);               #zero array -- all points get degree 0 
- 
-topaz > $F = vietoris_rips_filtration<Rational>($D,$a,0.1,4); 
-</code> 
-If you want to visualize specific frames of the filtration, use the ''vietoris_rips_complex'' function instead, passing the distance matrix and the desired distance parameter. 
-<code> 
-vietoris_rips_complex($D,1.4)->VISUAL; 
-</code> 
- 
- 
-{{ user_guide:rp2_filtration.png?600|}} 
-===== Computing Persistence ===== 
-There are two different functions, one to compute persistent homology for coefficients from arbitrary euclidean domains, and another for computing persistence barcodes for field coefficients. Both are templated by the boundary matrix type. The following examples compute both for this filtration of the 5-simplex, whose 3rd frame is the real projective plane: 
- 
-==== Coefficients from arbitrary euclidean domains ==== 
- 
-The function for coefficients from arbitrary euclidean domains takes as parameters a filtration object matching the matrix type and indices ''i,p,k''. It outputs a sparse matrix containing (as rows) the generators of the torsion-free part of the ''p''-persistent ''k''-th homology group of the ''i''-th frame, and a list of paired torsion coefficients and corresponding generator matrices. 
- 
-The following code loads a filtration object with Integer coefficients containing the example that was previously saved to disk, which you can download {{ user_guide:filtrationexample.top |here}}. It then computes the 3-persistent first homology group of frame 0, with the result that the torsion-free part is empty, and the part with torsion coefficient 2 has one generator, namely ''-v_0+v_1-v_5'': 
- 
-<code> 
- topaz > $F = load_data("FiltrationExample.top"); 
- topaz > print persistent_homology<SparseMatrix<Integer>>($F,0,3,1); 
-<> 
-<(2, <(15) (0 -1) (1 1) (5 -1)>)> 
-</code> 
- 
-==== Field coefficients and barcodes ==== 
- 
-{{ user_guide:barcode.png?200|}}The function for field coefficients requires only a filtration object of matching type as parameter. The output is an array with an entry for each dimension, containing a list of persistence intervals encoded as tuples of integers (where -1 encodes infinite lifetime). The following computes the intervals of the same filtration as above but with rational coefficients, downloadable {{ user_guide:filtrationexamplerational.top |here}}. 
- 
-<code> 
- topaz > $F2 = load_data("FiltrationExampleRational.top"); 
- topaz > print persistent_homology<SparseMatrix<Rational>>($F2); 
-{(0 2) (0 -1)} 
-{(2 3) (2 3) (2 3) (1 3) (2 3) (0 3)} 
-{} 
-{} 
-{} 
-{} 
-{} 
-</code> 
- 
-The output corresponds to the barcode on the right. 
  • user_guide/tutorials/persistent_homology.txt
  • Last modified: 2019/02/04 22:55
  • by 127.0.0.1