N <- 100 # The number of points to sample
set.seed(123) # Set a random seed for reproducibility
# Sample N points uniformly from the unit circle and add Gaussian noise
theta <- runif(N, min = 0, max = 2 * pi)
X <- cbind(cos(theta), sin(theta)) + rnorm(2 * N, mean = 0, sd = 0.2)
# Compute the persistence diagram using the Rips filtration built on top of X
# The 'threshold' parameter specifies the maximum distance for building simplices
D <- TDAstats::calculate_homology(X, threshold = 2)
# Compute algebraic functions for homological dimension H_0
computeAlgebraicFunctions(D, homDim = 0)
# Compute algebraic functions for homological dimension H_1
computeAlgebraicFunctions(D, homDim = 1)
Run the code above in your browser using DataLab