ws_logpca: Computes Wasserstein principal components

Description Usage Arguments Details Value References Examples

View source: R/logpca_nongrid.R

Description

Computes principal components in the 2-Wasserstein Space for a dataset of weighted point measures in R^2.

Usage

1
ws_logpca(data.list, barycenter, pca.count, steps_number = 21)

Arguments

data.list

A list of objects of which the principal components should be computed. Each element should be one of the following: A matrix, representing an image; A file name containing an image; A wpp-object; A pp-object; A list containing an entry 'positions' with the support of the measure and an entry 'weights' containing the weights of the support points; A list containing en entry 'positions' specifying the support of a measure with uniform weights.

barycenter

A barycenter of the dataset. See data.list for possible object types.

pca.count

An integer specifying the number of principal components to be computed.

steps_number

An integer specifying the number of discretisation steps for the output of the principal components.

Details

This function computes the principal components of a dataset consisting of weighted point measures in R^2. To do this it first maps the data to the tangent space at the barycenter and then performs standard Euclidean PCA on this space. Afterwards the resulting components are mapped back to the 2-Wasserstein space.

Value

A list with two entries. The first contains a list (of length pca.count), where each entry is a list of wpp-objects specifying one point on the corresponding principal component. The second entry is a vector containing the eigenvalues of the computed principal components. The output can be plotted by applying plotGeodesic to each component of the list.

References

E Cazelles, V Seguy, J Bigot, M Cuturi, and N Papadakis (2017); Log-PCA versus Geodesic PCA of histograms in the Wasserstein space. SIAM Journal on Scientific Computing 40(2):B429–B456.
W Wei, D Slepcev, S Basu, JA Ozolek, and GK Rohde (2013). A Linear Optimal Transportation Framework for Quantifying and Visualizing Variations in Sets of Images. International Journal of Computer Vision 101(2):254-269.

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
set.seed(2020)
N<-20
supp.size<-10^2
L<-sqrt(supp.size)
d<-2
data.list<-vector("list",N)
image.list<-vector("list",N)
for (i in 1:N){
  t.vec<-seq(0,2*pi,length.out=supp.size)
  pos<-cbind(cos(t.vec)*runif(1,0.2,1),sin(t.vec)*runif(1,0.2,1))
  theta<-runif(1,0,2*pi)
  rotation<-matrix(c(cos(theta),sin(theta),-1*sin(theta),cos(theta)),2,2)
  pos<-pos%*%rotation
  pos<-pos+1
  pos<-pos/2
  W<-rep(1/supp.size,supp.size)
  data.list[[i]]<-transport::wpp(pos,W)
}

res1<-wasserstein_bary(data.list,return_type = "wpp",method="alternating",
supp.size = supp.size,warmstartlength = 2,pos_maxIter = 50,
weights_maxIter = 0,maxIter = 1,stepsize=1)
pcomps<-ws_logpca(data.list,res1,3)
## Set the image and/or gif flags to TRUE to run the example. 
## CRAN policy prevents examples from generating files in the working directory,
## so this had to be disabled.
plotGeodesic(pcomps$components[[1]],File="PCA1",images=FALSE,gif=FALSE)
plotGeodesic(pcomps$components[[2]],File="PCA2",images=FALSE,gif=FALSE)
plotGeodesic(pcomps$components[[3]],File="PCA3",images=FALSE,gif=FALSE)

WSGeometry documentation built on Dec. 15, 2021, 1:08 a.m.