if(require("TDAstats"))
{
# create two diagrams
D1 <- TDAstats::calculate_homology(TDAstats::circle2d[sample(1:100,10),],
dim = 0,threshold = 2)
D2 <- TDAstats::calculate_homology(TDAstats::circle2d[sample(1:100,10),],
dim = 0,threshold = 2)
g <- list(D1,D2)
# calculate their distance matrix in dimension 0 with the persistence Fisher metric
# using 2 cores
D <- distance_matrix(diagrams = g,dim = 0,distance = "fisher",sigma = 1,num_workers = 2)
# calculate their distance matrix in dimension 0 with the 2-wasserstein metric
# using 2 cores
D <- distance_matrix(diagrams = g,dim = 0,distance = "wasserstein",p = 2,num_workers = 2)
# now do the cross distance matrix, which is the same as the previous
D_cross <- distance_matrix(diagrams = g,other_diagrams = g,
dim = 0,distance = "wasserstein",
p = 2,num_workers = 2)
}
Run the code above in your browser using DataLab