# From Trees to Barcodes and Back Again: Theoretical and Statistical Perspectives
## 5 Computational Exploration of Tree-Realization
### Statistics of Changing Classes  
Motivated by the theoretical results on the probability to change classes in Section 4.2, we analyze here several simulations of gradual switching of death order of two bars and the resulting effect on tree realizations and their associated barcodes. Let \(B\) be a strict barcode, and let \((b_{i},d_{i}),(b_{j},d_{j})\) be bars of \(B\) such that \(d_{i}<d_{j}\). By Lemma 5, for a fixed choice of the parameter \(\lambda\) (cf. Section 2.4), the probability that the order of these two bars is reversed in TMD \(\circ\) TNS\((B)\) depends exponentially on the distance between \(d_{i}\) and \(d_{j}\):  
\[\mathbb{P}(d_{j}^{\prime}<d_{i}^{\prime})=\frac{1}{2}\exp(-\lambda(d_{j}-d_{i} )).\]  
Thus, when the distance between \(d_{i}\) and \(d_{j}\) decreases, the probability that the order of bars changes increases. When there is no \(k\) such that \(d_{i}<d_{k}<d_{j}\), Proposition 1 provides a formula for the  
Figure 17: Barcode-equivalence class, represented by the corresponding permutation, (**A**) and persistence diagram (**B**) of 100 synthesized cells based on a geometric tree with eight branches, extracted from a layer 4 pyramidal cell. The barcode-equivalence classes of the synthesized trees (represented by blue dots) can differ from that of the original tree due to the stochastic nature of synthesis algorithm. The persistence diagrams of the synthesized trees ((**B**), blue) are essentially indistinguishable from those of the original tree ((**B**), red). tree-realization number of the new barcode obtained when such a switch happens, as long as the order of the birth times is not also reversed. We start with a geometric tree \(T\) extracted from a digital reconstruction of a neuron and compute its associated barcode \(B=\mathrm{TMD}(T)\). We choose two bars \((b_{i},d_{i})\) and \((b_{j},d_{j})\) of \(B\) that are consecutive in the order of deaths and divide the interval \((d_{i},d_{j})\) into 50 equally sized subintervals. For \(0\leq k\leq 50\), let \(B_{k}\) be a barcode that is identical to \(B\), except that its \(i\)th bar is \(\left(b_{i},d_{i}+k(d_{j}-d_{i})/50\right)\) and its \(j\)th bar is \(\left(b_{j},d_{j}-k(d_{j}-d_{i})/50\right)\). An interesting way to visualize this change is to think of \(B_{k}\) as migrating along the edge between \(B\) and the barcode with \(d_{i}\) and \(d_{j}\) permuted in the corresponding Cayley graph as \(k\) increases. The middle point of the edge corresponds to the non-strict barcode for which the two deaths are equal. Let \(B_{k}^{\prime}=\mathrm{TMD}\circ\mathrm{TNS}(B_{k})\) for all \(k\). Because of the stochastic nature of the TNS algorithm, the permutation equivalence class of \(B_{k}^{\prime}\) may be different from that of \(B_{k}\). Figure 18 provides an example of this construction, where the barcodes are represented as persistence diagrams for visualization purposes (cf. Section 2.2). To test whether the barcode \(B_{k}^{\prime}\) is equivalent to the original barcode \(B\), we compute its tree-realization number: if \(\mathrm{TRN}(B_{k}^{\prime})\
eq\mathrm{TRN}(B)\), then \(B\) and \(B_{k}^{\prime}\) are not equivalent. Note that, for the specific process that gives rise to \(B_{k}\), it is likely that only the studied death-switch could lead to a difference between the tree-realization numbers of the input and output barcodes, unless two other deaths are too close to each other in the input barcode, as in the last row of Figure 19, which we explain further below. Therefore, the tree-realization number provides a very good indication of whether the switch of deaths took place, i.e., if \(B\sim B_{k}^{\prime}\) or not. Indeed, two barcodes that are the same except for two deaths that switched have different tree-realization numbers, cf. Proposition 1. Figure 19 shows several examples of the endpoint-switching process described above and the corresponding evolution of the tree-realization number as \(k\) increases.