if(require("TDAstats"))
{
# create two independent groups of diagrams of length 6, which
# is the minimum length
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)
g1 <- list(D1,D2,D2,D2,D2,D2)
g2 <- list(D2,D1,D1,D1,D1,D1)
# do independence test with sigma = t = 1 in dimension 0, using
# precomputed Gram matrices
K = gram_matrix(diagrams = g1,dim = 0,t = 1,sigma = 1,num_workers = 2)
L = gram_matrix(diagrams = g2,dim = 0,t = 1,sigma = 1,num_workers = 2)
indep_test <- independence_test(Ks = list(K),Ls = list(L),dims = c(0))
}
Run the code above in your browser using DataLab