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)
scaleSeq = seq(0, 2, length.out = 11) # A sequence of scale values
# Compute vector summaries of the first three persistence landscape functions
# for homological dimension H_1
computePersistenceLandscape(D, homDim = 1, scaleSeq, k = 3)
# Compute vector summaries of the first three generalized persistence
# landscape functions (with triangle kernel and bandwidth h=0.2)
# for homological dimension H_1
computePersistenceLandscape(D, homDim = 1, scaleSeq, generalized = TRUE, k = 3, h = 0.2)
Run the code above in your browser using DataLab