{'fraction_non_alphanumeric': 0.02870699881376038, 'fraction_numerical': 0.01640964808224595, 'mean_word_length': 4.404059829059829, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 3, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Improved Modeling of Persistence Diagram

High-dimensional reduction methods are powerful tools for describing the main patterns in big data. One of these methods is the topological data analysis (TDA), which modeling the shape of the data in terms of topological properties. This method specifically translates the original data into two-dimensional system, which is graphically represented via the 'persistence diagram'. The outliers points on this diagram present the data pattern, whereas the other points behave as a random noise. In order to determine which points are significant outliers, replications of the original data set are needed. Once only one original data is available, replications can be created by fitting a model for the points on the persistence diagram, and then using the MCMC methods. One of such model is the RST (Replicating Statistical Topology). In this paper we suggest a modification of the RST model. Using a simulation study, we show that the modified RST improves the performance of the RST in terms of goodness of fit. We use the MCMC Metropolis-Hastings algorithm for sampling according to the fitted model.


Introduction
Topological data analysis (TDA) is an emerging field in which topological properties of data are analyzed ( [12]). This should provide useful information about the structure and geometry of the data. The idea is to reduce high dimensional data sets to lower dimensions without sacrificing their most relevant topological properties. It is done by four steps ( [9]): First, the given data set (which contains data samples in the rows and multiple attributes in the columns) is converted into a 'point cloud' by calculating the similarity value using some distance metric. That is, every row in the given data is extracted into a single data point in the point cloud. Next, the point cloud is converted into a simplicial complex, and based on it, homology groups, which are algebraic analogues of certain properties of the manifold, are constructed. Specifically, persistent homology computes topological features of the manifold at different spatial resolutions.
More persistent features are detected over a wide range of spatial scales and are deemed more likely to represent true features of the underlying space rather than artifacts of sampling, noise, or particular choice of parameters. Persistent homology techniques reveal topological features such as connected components, holes, and voids. Finally, these topological features are summarized in a 'persistence diagram' (PD), a multiset of points in R 2 that tracks the information about the "birth" and "death" scale of each topological feature. The difference between the birth and death scales is called the persistence of a feature and in some sense indicates its prominence. Given the topological features, the question of statistical inference is arise, and there exist a literature on this issue: [6] studied the persistence diagram with deterministic measure on R 2 ('Expected Persistence Diagram' ( [7])), and discussed the density of such diagrams, and a kernel based estimation of this density; [11] showed that the space of persistence diagrams has properties that allow to define on it expectation, variance, percentile and conditional probability; [10] studied the expectation of a persistence diagram by the persistence weighted kernel; [15] suggested the Fréchet Means for Distributions of Persistence Diagrams.
For generating multiple instances of persistence diagrams when only one such original diagram is available, there exist two approaches in the literature: One approach is the bootstrap approach as in [5] and [8]; this approach produces replicates of persistence diagram by subsampling either the data or the diagram. Another approach is the RST that was suggested by [1], and was improved in [2]. The RST is a parametric modeling of the points on a single diagram having the same rank of homology. It is based on a Gibbs model that involves the distances of the K nearest neighbours of each point of the persistence diagram, multiplying by the kernel density estimator (KDE). The model's parameters are estimated via the maximum likelihood method. However, sometimes, no maximal solution exists, i.e., the estimation diverges. Such cases arises, for example, when the number of points on the persistence diagram for a given homology rank is relative large, and the points are dense. Then the distances of the K nearest neighbors are relative small, which lead to increase more and more the value of the optimization solution, and divergence is obtained. By this, the log likelihood becomes undefined when no constrains are taken on the parameters values. One possible solution is to put some weight on each closeness level of the nearest neighbors. A reasonable weight is the KDE. That is, instead of weighting all levels of distance closeness levels of the nearest neighbours together, the weighting will be on each level of distance closeness of the nearest neighbours. In this paper we examine the goodness of fit of this modification, and compare it with the performance of the original RST. The outline of the paper is as follows. Section 2 presents the notation and background, and gives a short description of the RST method along with the suggested modified model. Section 3 examined the performance and goodness of fit of the suggested modified model via a simulation study. Section 4 describes the results, and Section 5 presents a brief summary and conclusions.

Background and setting 2.1 Notation
Let Z be a compact subset of R D , typically a sub-manifold or stratified submanifold, and suppose that we observe a sampleZ n = {Z 1 , . . . , Z n } drawn from a distribution P supported on Z. For defining the persistence diagram of a dataset in computational topology, one can use for example the usual distance function, or a smooth function such as the kernel density estimator. The points on the persistence diagram are 'birth' and 'death' and are denoted by where N is the number of points that have the same rank of homology k.

The RST Model
has the effect of moving the points in the original persistence diagram downwards, so that the diagonal line projects onto the horizontal axis, but still leaves a visually informative diagram, which [1] call the projected persistence diagram, or PPD. The goal is a parametric model forx N . The description of the suggested model of [2] is as follows. Define a kernel density estimator (KDE),f n , given byf where η > 0 is a bandwidth parameter for the Gaussian kernel definingf n . In addition, for x ∈ X and for k ≥ 1 let x nn (k) ∈ X be the k-th nearest neighbour to x, and set where Θ = (θ 1 , . . . , θ K ), and K is the cluster size. Then, the likelihood (pseudolikelihood [3,4]) is where N K (x) denotes the K nearest neighbours of x inx N , and For considering some values of K, the best model can be chosen by the automated statistical procedures such as AIC, BIC, etc. The nuisance parameter α is estimated by the bisection method, where after considerable experimentation, [2] found that it is enough to take the search (non-negative) range to be [0, 3]. Given the value of α that maximizes the log likelihood, the next step is searching for Θ that maximizes the log likelihood.

The Modified RST Model
The density function (2.5) is weighting the KDE over all the closeness levels of the nearest neighbors. The suggested modification is to weight the KDE separately for each closeness level of the nearest neighbors. That is, based on Then, the likelihood is where N K (x) denotes the K nearest neighbours of x inx N , and

Algorithm for replicated persistence diagrams
Based on the RST model, [2] used the Metropolis-Hastings MCMC [13,14] to generate simulated replications of the points on the original persistence diagram, as follows. Firstly, given ax N , define a 'proposal distribution' q(·|x N ) to be the KDE by using the inverse transform method [13,14]. Next, for two points x, x * ∈ R × R + define an 'acceptance probability', according to which x ∈x N is replaced by x * , leading to the updated PPDx * N , as .
Then the algorithm is Algorithm 1.
To obtain B approximately independent PPD's, the procedure dependents on a burn in period, see [1] SI Appendix (Sec. 2.1) for more details. Given the collection of B simulated PPDs, each PPD is converted back to a regular persistence diagram with the mapping x m → (x

Goodness of Fit
The goodness of fit of each model versions is the degree of closeness between the resulted simulated PD by each model version with the real PD. In order to evaluate the goodness of fit of the modified RST relative to the performance of the original RST, a simulation study was used, and it is presented below in Section 3. The general idea is as follows. We calculated 100 real PDs corresponded to 100 samples from some geometrical object, one PD for each sample. For each PD, we fitted both the original and the modified models. Then we calculated the simulated PD using the Metropolis-Hastings algorithm based on each of the two fitted models. As the next step, we examined two criteria of goodness of fit over the 100 PDs. Criterion 1 is the distance between the real PD and its corresponded simulated PD, using the Bottleneck and the Wasserstein distances. Smaller distances indicate on a better fitting. The bottleneck distance is the cruder of the two distances, and the Wasserstein distance is more sensitive to details in the persistence diagram [? ]. Criterion 2 is a comparison of distributional properties of the real PDs with those of the simulated PDs: We used as the distributional properties the averaged distances of the first, second, and third nearest neighbors. Using the distributions of these criteria over the 100 PDs made the comparison of goodness of fit of the modified model vs. the original model.

Simulation Study
In the simulation study we took the various data to be of two, three, and forth dimensions. For the two dimensional data we examined the one unit circle, two concentric circles, and two distinct circles. These examples behave as one, two, and separated geometrical objects, respectively. For the three and four dimensional data sets we consider the unit 2-sphere (S 2 ) and the unit 3-sphere (S 3 ), respectively. In each example, the persistence diagram was generated by the upper level sets of a smoothed empirical density of the data, as defined in (2.1), with η = 0.1. The grid for the calculation of this density was based on 100 points over the range of each coordinate. We used this grid in the all considered examples except the example of S 3 which has 4 dimensions, and due to computer's memory we took the grid to be based on 15 points over the range of each coordinate. For the calculations of the model likelihood, we used the plug-in bandwidth for the KDE as obtained by the function Hpi.diag in R software ("ks" package). In addition, we took the search for α estimator over the range [0,4]. Some notes regarding the MCMC algorithm that we used: (i) The KDE as the 'proposal distribution' had sometimes a negligible value, which should be ignored. Therefore, for each example in the simulation study, we dropped the proposal values that had KDE< 10 −4 . (ii) The proposal distribution is based on a two-dimensional grid to sample from it. In [2], the optimal grid was considered, but it had resulted in a low acceptance rate in the MCMC. Generally, the acceptance rate is a one measure for the goodness of the MCMC algorithm performance. It depends largely on the proposal distribution, where distribution with smaller variance is resulted in a higher acceptance rate, and vice versa. Usually, the standard rate of acceptance is supposed to be around 0.2-0.25. But, using the original grid in the proposal distribution yields a smaller rate relative to that obtained by the standard grid. Increasing the grid size yields a better acceptance rate. More of that, increasing the grid size is itself better since the aim of the proposal distribution is to approximate the distribution of the points on the PD, therefore a finer grid may obtain better results. For these two reasons, we examined the performance of the MCMC under the grids of 25x25, 50x50, 100x100. (iii) For the burn-in parameter (which we call 'step' in the following results), we examined the values of 25, 50, 100, and we took the PD at that step to be the simulated PD.

One geometrical object
As one geometrical object data we took a sample of n = 1000 points drawn from a circle with radius r = 1 (the unit circle). The typical corresponded persistence diagram is presented in Figure 1. The black circles indicating connected components (H 0 persistence), and the red triangles corresponding to holes (H 1 ).
We generated 100 such samples, and calculated their corresponded PDs. For each PD we fitted both the original and modified models for the H 0 points, according to the steps that were mentioned above in Section 2.5. Figure 2 describes the distributions over the 100 PDs of the first criterion of goodness of fit, and Figures 3-4 describe the distributions of the second criterion of goodness of fit. In criterion 1, we have that the distance of the simulated PD from the real PD is smaller under the modified model relative to the distance under the original model. This is prominent in the Wasserstein distance, as expected due to its sensitivity to details in the PD, as was mentioned in Section 2.5. For a given grid, the burn-in value over the considered values has a negligible influence on both distances. But the larger grid size (for a given burn-in) yields smaller distances for both model's versions. For criterion 2, the distributional properties of the modified model are close to those of the real PDs rather those of the original model, for all considered values of the grid size and the burn-in. More of that, the grid sizes of 50x50 and 100x100 are better in terms of the first, second and third nearest neighbors, and step of 25 is the best for each of them. That is, based on criteria 1-2 we conclude for this example that the modified RST is better than the original RST, where the best fitting is under grid sizes of 50x50 and 100x100, and burn-in of 25.

Two geometrical objects
In the contrary to the previous example that included one geometrical object, the following example describes two geometrical objects, and specifically two concentric circles: one circle has a radius r 1 = 0.5, and the second circle has a radius r 2 = 1.2. For a sample size of n points from this geometrical object, the number of points of the smaller circle and the larger circle is 0.4n and 0.6n, respectively. The both circles together obtain a smaller circle inside a larger one. We consider a sample of n = 1, 000 points from this object. The typical object is presented in the left side of Figure 5. Its corresponded persistence diagram is presented in the right side of Figure 5. We generated 100 such samples, calculated their corresponded PDs, and fitted the both model's versions for the H 0 points of each PD. Figure 6 describes the distributions over the 100 PDs of the first criterion of goodness of fit, and Figures 7-8 describe the distributions of the second criterion of goodness of fit. In criterion 1, the Wasserstein distance between the simulated PD and the real PD is smaller under the modified model relative to this distance under the original model. For this distance, the best fitting is in burn-in of 25, and the distance decreases as the grid size increases. The Bottleneck distances are relative similar for both model's versions, with a similar impact of the grid size and the burn-in value.
For criterion 2, the distributional properties of the modified model are close to those of the real PDs rather than the distributional properties of the original model. This is true for all considered values of grid size and burn-in. Specifically, given a burn-in of 25, the fitting is better in grid size of 100x100 for the three distributional properties, whereas given a burn-in of 50, 100, the fitting is better in grid of 25x25 for the second and third properties, and is better in grid of 100x100 for the first property.
That is, here as in the previous example, that the modified RST is better than the original RST, where the best fitting is under grid sizes of 50x50 and 100x100, and burn-in of 25.

Two separated geometrical objects
While the previous example contained data of two circles, this example contains data of two distinct circles. One circle has a radius r 1 = 0.5, the second circle has a radius r 2 = 1.2, and the distance between these two circles is 1.5 for each point. We consider a sample of n = 1, 300 points, where the number of points on each circle is 650. The typical sample is presented in the left side of Figure 9. To its right, we have its corresponded PD. We generated 100 such samples, calculated their corresponded PDs, and fitted the both model's versions for the H 0 points of each PD. Figure 10 describes the distributions over the 100 PD of the first criterion of goodness of fit, and Figures 11-12 describe the distributions of the second criterion of goodness of fit. In criterion 1, the Bottleneck distance between the simulated PD and the real PD is better under the modified model relative to that distance under the original model. This distance's distribution is similar for all considered values of grid size and burn-in. In Wasserstein distance, the best fitting is under the modified model relative to the fitting under the original model. Moreover, the fitting in Wasserstein distance is better (that is, a smaller distance) as the grid size increases for a given step, and this fitting is better for step of 25 given a specific considered value of grid size. For criterion 2, the distributional properties of the modified model are better than those of the real PDs for each considered value of grid size and the burn-in. That is, for this example we have that the modified RST is better than the original RST, where the best fitting is under grid sizes of 50x50 and 100x100, and burn-in of 25.

2-Sphere (S 2 )
This example includes a random sample of n = 1, 000 points from the uniform distribution on the sphere S 2 in R 3 with radius r = 1.
The typical corresponded persistence diagram is presented in Figure 13. The black circles indicating connected components (H 0 persistence), the red triangles corresponding to holes (H 1 ), and the blue diamond corresponding to void (H 2 ). The next plots to its right present the persistence diagram for each homology separately, except H 2 which has only 1 point.     Figure 17 describes the distributions over the 100 H 1 PDs of the first criterion of goodness of fit, and Figures 18-19 describe the distributions of the second criterion of goodness of fit. For criterion 1, we have, as in setting of H 0 PDs, that the modified model is better than the original (that is, smaller distance of the PDs under the modified model from the real PDs relative to that distance based on the original model). But, for the H 1 PDs, the advantage of the modified model is less extreme relative to the setting of H 0 PDs. That is, the distances distributions of the modified simulated PDs and those of the original simulated PDs are relative close in the setting of H 1 PDs comparing to these distributions in the setting of H 0 PDs. In the same way, we have in criterion 2 that the distributions of the first, second, and third distances, in the real, original model, and modified model, are much similar comparing with these distributions under H 0 PDs. Accordingly, the closeness of these distributions under the modified model to these under the real PDs is better for all considered values of burn-in and grid size in H 1 than in H 0 . The reason for these different results in H 1 comparing to H 0 is the larger variability of the H 0 PD points relative to that of H 1 PD points, see for example in Figure 13. Note that according to criterion 2, the modified model for a given grid size is better under burn-in of 25, and the fitting is better in grid size of 100x100 for a given burn-in.

3-Sphere (S 3 )
This example includes a random sample of n = 1, 000 points from the uniform distribution on the sphere S 3 in R 4 with radius r = 1.
The typical corresponded persistence diagram is presented in the left side Figure 20. The black circles indicating connected components (H 0 persistence), the red triangles corresponding to holes (H 1 ), the blue diamonds corresponding to voids (H 2 ), and the green points to H 3 . The next plots to its right present the persistence diagram for each homology separately, except H 3 which has only 3 points.     Based on criterion 1, the modified model seems better under the both distance measures, that is, the distance of simulated based on the modified model is smaller than that under the original model. This is especially prominent in the Wasserstein distance. As in the S 2 example, the advantage of the modified model under the H 1 PDs is less extreme relative to the setting of H 0 PDs. The Wasserstein distance has higher values in H 0 than in H 1 . The Bottleneck distance is a little higher in H 0 than in H 1 , but still has moderate values relative to the values of Wasserstein distance. The reason for these results is the large variability in the points on the persistence diagrams H0 relative to H1.
Bases on criterion 2, as in H 0 , the distributional properties for small grid sizes under the original model are close to those of the real PDs than the the distributional properties under the modified model. But the contrary for grid size of 100x100 and burn-in of 25, where properties of the modified model are close to these properties of the real PDs. The same variability of these distributions that had observed in H 0 also can be seen here for H 1 .    Here we see a different pattern at the distribution shape of the properties under criterion 2 relative to this shape in H 0 and H 1 : the shape of the distributions is different for the the modified model than these shape for the original model and the real PDs. The reason is the different shape of the points on the H 2 PD relative to this shape of the H 0 and H 1 points.
Based on criterion 1, the modified model seems better under the both distance measures, but still behave close under the Bottleneck distance whereas the advantage of the modified model is prominent in the Wasserstein distance. Relative to these distances in H 0 and H 1 points, the Bottleneck distances of the modified and the original models are similar in H 2 relative to these distances in H 0 and H 1 . In addition, the values of the Bottleneck and Wasserstein distances are smaller for the both models in H 2 than in H 0 and H 1 . The reason for these results is the large variability in the points on the persistence diagrams H0 and H1 relative to H2.

Distribution of the estimates
Constraining the search range for the estimation of α as we saw in S 3 for H 2 points gives a motivation to compare the range of α estimates over the examined settings. In addition, by this, it is interesting to see if and how the distribution of the estimates of α (denoted byα) influent the distribution of Θ estimates (denoted byΘ). For this purpose, we distinguished between the different combinations of signs of θ 1 , θ 2 , θ 3 estimates, and examined the range of α estimates for each such combination. Table 1 summarizes the results. We see that the range ofα is pretty similar for the different combinations ofΘ signs, except the case ofΘ > 0 which has small values toward zero ofα. The later case is generally for all the examined examples except for S 3 in H 2 points which has a weight of 29%. The common case is ofθ 1 > 0,θ 2 < 0,θ 3 < 0.

Results
Generally, in all the considered examples we have that, based on the examined criteria, the modified RST behave better than the original one in fitting the distribution of the points on the PD (for a given homology). Specifically, for the two-dimensional examples, which include one or two geometrical objects, the modified RST is better for all considered grid sizes and burn-in values, but the best fitting is in grid sizes of 50 and 100, and burn-in of 25. But for the three and four dimensional examples, the modified RST is better only in grid size of 100 and burn-in of 25. The reason for the need in large grid in the later examples is to capture the large variability of the points on the PD due to the high dimensionality.

Summary
In this paper suggest a modified RST for modeling the points on persistence diagram. We examined the performance of this modified version relative to the original one by using two criteria. We have found that the modified RST fits the distribution of the points on the persistence diagram better than the original RST. Particularly, the best fitting is achieved usually in a larger grid for which the proposal distribution of the MCMC algorithm is calculated (in our simulations, grid sizes of 50 or 100), and in a smaller burn-in of the MCMC algorithm (in our simulations, burn-in of 25). Therefore we recommend to use the modified RST with considering these values of the MCMC parameters.