if(require("TDAstats"))
{
# create two diagrams
D1 <- TDAstats::calculate_homology(TDAstats::circle2d[sample(1:100,20),],
dim = 1,threshold = 2)
D2 <- TDAstats::calculate_homology(TDAstats::circle2d[sample(1:100,20),],
dim = 1,threshold = 2)
# calculate the kernel value between D1 and D2 with sigma = 2, t = 2 in dimension 1
diagram_kernel(D1,D2,dim = 1,sigma = 2,t = 2)
# calculate the kernel value between D1 and D2 with sigma = 2, t = 2 in dimension 0
diagram_kernel(D1,D2,dim = 0,sigma = 2,t = 2)
}
Run the code above in your browser using DataLab