<Chapter><Heading>Topological data analysis</Heading>
<Section><Heading>Persistent homology  </Heading>

<P/>Pairwise distances between <M>74</M> points from some 
 metric space have been recorded and stored in a <M>74\times 74</M> 
matrix <M>D</M>. The following commands load the matrix, construct a 
filtration of length <M>100</M> on the first two dimensions of the assotiated clique complex (also known as the <E>Rips Complex</E>), and display the resulting degree <M>0</M> persistent homology as a barcode. A single bar with label <M>n</M> denotes <M>n</M> bars with common starting point and common end point.

<Example>
<#Include SYSTEM "tutex/4.1.txt">
</Example>
<Alt Only="HTML">&lt;img src="images/bar0.png" align="center" height="60" alt="degree 0 barcode"/>
</Alt>

<P/>
The next commands display the resulting degree <M>1</M> persistent homology as a barcode.

<Example>
<#Include SYSTEM "tutex/4.2.txt">
</Example>

<Alt Only="HTML">&lt;img src="images/bar1.png" align="center" height="120" alt="degree 1 bar code"/>
</Alt>

<P/> The following command displays the <M>1</M> skeleton of the simplicial complex arizing as the <M>65</M>-th term in the filtration on the clique complex.

<Example>
<#Include SYSTEM "tutex/4.3.txt">
</Example>
<Alt Only="HTML">&lt;img src="images/twocircles.png" align="center" height="300" alt="1-skeleton"/>
</Alt>

<P/>These computations suuggest that the dataset contains two persistent 
path components (or clusters), and that each path component is in some sense periodic. The final command displays one
 possible representation of the data as points on two circles.

<Subsection><Heading>Background to the data</Heading>

<P/>Each point in the dataset was an image consisting of <M>732\times 761</M> pixels. This point was regarded as a vector in <M>\mathbb R^{732\times 761}</M> and the matrix <M>D</M> was constructed using the Euclidean metric. The images were the following:
<P/>
<Alt Only="HTML">&lt;img src="images/letters.png" align="center" height="220" alt="letters"/>
</Alt>

</Subsection>
</Section>

<Section><Heading>Mapper clustering</Heading>

<P/>The following example reads in a set <M>S</M> of vectors of rational numbers. It uses the Euclidean distance <M>d(u,v)</M> between vectors. It  fixes     
some  vector $u_0\in S$ and uses the associated
function <M>f\colon D\rightarrow [0,b] \subset \mathbb R, v\mapsto d(u_0,v)</M>.  In addition, it uses an open cover of the interval <M>[0,b]</M> consisting of
<M>100</M> uniformly distributed overlapping open subintervals of radius <M>r=29</M>. It also uses a simple clustering algorithm implemented in the function
<C>cluster</C>.

<P/> These ingredients are input into the Mapper clustering procedure to 
produce
 a simplicial complex <M>M</M> which is intended to be a representation of the 
data. The complex <M>M</M> is <M>1</M>-dimensional and the final command uses 
GraphViz software to visualize the graph. The nodes of this simplicial 
complex are "buckets" containing data points. A data point may reside in several buckets. The number of points in the bucket determines the size of the node. Two nodes are connected by an edge when their end-point nodes contain common data points.
<Example>
<#Include SYSTEM "tutex/4.4.txt">
</Example>
<Alt Only="HTML">&lt;img src="images/mapper.png" align="center" height="300" alt="Mapper graph"/>
</Alt>


<Subsection><Heading>Background to the data</Heading>

<P/> The datacloud <M>S</M> consists of the <M>400</M> points in the plane shown in the following picture.

<P/>
<Alt Only="HTML">&lt;img src="images/mappercloud.png" align="center" height="400" alt="data cloud"/>
</Alt>

</Subsection>
</Section>

<Section><Heading>Digital image analysis</Heading>

<P/>The following example reads in a digital image as a filtered
pure cubical complexex.
The filtration is obtained by thresholding at a sequence of uniformly spaced values  on the greyscale range. The persistent homology of this filtered complex is calculated in degrees <M>0</M> and <M>1</M> and displayed as two barcodes.

<Example>
<#Include SYSTEM "tutex/4.5.txt">
</Example>

<Alt Only="HTML">&lt;img src="images/imbar0.gif" align="center" height="400" alt="barcode"/>
</Alt>

<Example>
<#Include SYSTEM "tutex/4.6.txt">
</Example>


<Alt Only="HTML">&lt;img src="images/imbar1.gif" align="center" height="400" alt="barcode"/>
</Alt>

<P/>The <M>20</M> persistent bars in the
degree <M>0</M> barcode suggest that the image has <M>20</M> objects. The degree <M>1</M> barcode suggests that <M>14</M> (or possibly <M>17</M>) of these objects have holes in them.

<Subsection><Heading>Background to the data</Heading>

<P/>The following image was used in the example.
<P/>
<Alt Only="HTML">&lt;img src="../tst/examples/image1.3.2.png" align="center" height="500" alt="barcode"/>
</Alt>

</Subsection>
</Section>

<Section><Heading>Random simplicial complexes</Heading>
<P/>For a positive integer <M>n</M> and probability <M>p</M>
 we denote by <M>Y(n,p)</M> the <E>Linial-Meshulam random simplicial 2-complex</E>. Its <M>1</M>-skeleton is the complete graph on <M>n</M> vertices; each possible <M>2</M>-simplex is included independently with probability <M>p</M>.

<P/>The following commands first compute the number <M>h_i</M> of non-trivial cyclic summands in
<M>H_i(Y(100,p), \mathbb Z)</M> for a range of probabilities <M>p</M> and <M>i=1,2</M> and then
produce a plot of <M>h_i</M> versus <M>p</M>. The plot for <M>h_1</M> is red and the plot for <M>h_2</M> is blue. A plot for the Euler characteristic <M>1-h_1+h_2</M> is shown in green.

<Example>
<#Include SYSTEM "tutex/4.7.txt">
</Example>


<P/>
<Alt Only="HTML">&lt;img src="tutex/graph4.7.png" align="center" height="500" alt="a graph"/></Alt> <Alt Only="HTML">&lt;img src="tutex/graph4.77.png" align="center" height="500" alt="a graph"/>
</Alt>

<P/>From this plot it seems that there is a <E>phase change threshold</E> at around <M>p=0.025</M>. An inspection of the first homology
groups <M>H_1(Y(100,p), \mathbb Z)</M> shows that in most cases there is no torsion. However, around the threshold some of the complexes do have torsion in their first homology. 

<P/>Similar commands for <M>Y(75,p)</M> suggest a phase transition at around <M>p=0.035</M> in this case. The following commands compute <M>H_1(Y(75,p), \mathbb Z)</M>
for <M>900</M> random <M>2</M>-complexes with <M>p</M> in a small interval around <M> 0.035</M> and, in each case where there is torsion, the torsion coefficients are stored in a list. The final command prints these lists -- all but one of which are of length <M>1</M>. For example, there is one <M>2</M>-dimensional simplicial complex on <M>75</M> vertices whose first homology contains the summand <M>\mathbb Z_{107879661870516800665161182578823128}</M>.
The largest prime factor is <M>80555235907994145009690263</M> occuring in the summand
<M>\mathbb Z_{259837760616287294231081766978855}</M>.
<Example>
<#Include SYSTEM "tutex/4.8.txt">
</Example>

</Section>
</Chapter>
