## Distance Function Diagram and Kernel Density Diagram
# input data
n = 300
XX = circleUnif(n)
## Ranges of the grid
Xlim=c(-1.8,1.8)
Ylim=c(-1.6,1.6)
by=0.05
h = .3 #bandwidth for the function kde
#Distance Function Diagram of the sublevel sets
Diag1=gridDiag(XX,distFct, Xlim, Ylim, by=by, sublevel=TRUE, printStatus=TRUE)
#Kernel Density Diagram of the superlevel sets
Diag2=gridDiag(XX, kde, Xlim, Ylim, by=by, sublevel=FALSE, printStatus=TRUE, h=h)
#plot
par(mfrow=c(1,3))
plot(XX,cex=0.5, pch=19)
title(main="Data")
plot(Diag1)
title(main="Distance Function Diagram")
plot(Diag2)
title(main="Density Persistence Diagram")
Run the code above in your browser using DataLab