diag2silhouette: Convert Persistence Diagram into Persistent Silhouette

Description Usage Arguments Value Examples

View source: R/convert_diag2silhouette.R

Description

Persistence Silhouette (PS) is a functional summary of persistent homology that is constructed given a homology object. PS is a weighted average of landscape functions so that it becomes a uni-dimensional function.

Usage

1
diag2silhouette(homology, dimension = 1, p = 2, nseq = 100)

Arguments

homology

an object of S3 class "homology" generated from diagRips or other diagram-generating functions.

dimension

dimension of features to be considered (default: 1).

p

an exponent for the weight function of form |a-b|^p (default: 2).

nseq

grid size for which the landscape function is evaluated.

Value

a list object of "silhouette" class containing

lambda

an (\code{nseq} \times k) landscape functions.

tseq

a length-nseq vector of domain grid.

dimension

dimension of features considered.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# ---------------------------------------------------------------------------
#              Persistence Silhouette of 'iris' Dataset
#
# We will extract silhouettes of dimensions 0, 1, and 2.
# ---------------------------------------------------------------------------
## Prepare 'iris' data
XX = as.matrix(iris[,1:4])

## Compute Persistence Diagram 
pdrips = diagRips(XX, maxdim=2)

## Convert to Silhouettes of Each Dimension
sil0 <- diag2silhouette(pdrips, dimension=0)
sil1 <- diag2silhouette(pdrips, dimension=1)
sil2 <- diag2silhouette(pdrips, dimension=2)

## Visualize
opar <- par(no.readonly=TRUE)
par(mfrow=c(2,2))
plot(pdrips$Birth, pdrips$Death, col=as.factor(pdrips$Dimension),
     pch=19, main="persistence diagram", xlab="Birth", ylab="Death")
plot(sil0$tseq, sil0$lambda, type="l", lwd=3, main="dimension 0", xlab="t")
plot(sil1$tseq, sil1$lambda, type="l", lwd=3, main="dimension 1", xlab="t")
plot(sil2$tseq, sil2$lambda, type="l", lwd=3, main="dimension 2", xlab="t")
par(opar)

kyoustat/TDAkit documentation built on Sept. 1, 2021, 7:22 a.m.