fssum: Weighted Sum of Multiple Functional Summaries

Description Usage Arguments Value Examples

View source: R/summaries_sum.R

Description

Given multiple functional summaries Λ_1 (t), Λ_2 (t), …, Λ_N (t), compute the weighted sum

\bar{Λ} (t) = ∑_{n=1}^N w_n Λ_n (t)

with a specified vector of given weights w_1,w_2,…,w_N.

Usage

1
fssum(fslist, weight = NULL)

Arguments

fslist

a length-N list of functional summaries of persistent diagrams.

weight

a weight vector of length N. If NULL (default), weights are automatically set as w_1=\cdots=w_N = 1/N.

Value

a functional summary object.

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
26
27
28
29
30
31
32
# ---------------------------------------------------------------------------
#     Weighted Average of 10 Persistence Landscapes from '2holes' data
# ---------------------------------------------------------------------------
## Generate 10 Diagrams with 'gen2holes()' function
list_rips = list()
for (i in 1:10){
  list_rips[[i]] = diagRips(gen2holes(n=100, sd=2)$data, maxdim=1)
}

## Compute Persistence Landscapes from Each Diagram with k=5 Functions
list_land = list()
for (i in 1:10){
  list_land[[i]] = diag2landscape(list_rips[[i]], dimension=0, k=5)
}

## Some Random Weights
wrand = abs(stats::rnorm(10))
wrand = wrand/sum(wrand)

## Compute Weighted Sum of Landscapes
ldsum = fssum(list_land, weight=wrand)

## Visualize
sam5  <- sort(sample(1:10, 5, replace=FALSE))
opar  <- par(no.readonly=TRUE)
par(mfrow=c(2,3), pty="s")
for (i in 1:5){
  tgt = list_land[[sam5[i]]]
  matplot(tgt$tseq, tgt$lambda[,1:5], type="l", lwd=3, main=paste("landscape no.",sam5[i]))
}
matplot(ldsum$tseq, ldsum$lambda[,1:5], type="l", lwd=3, main="weighted sum")
par(opar)

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