gr.pdist2: Pairwise Distance for Two Sets Data on Grassmann Manifold

Description Usage Arguments Value Author(s) Examples

View source: R/gr_pdist2.R

Description

For data on grassmann manifold x_1,x_2,…,x_M \in Gr(k,n) and y_1,y_2,…,y_N \in Gr(k,n), compute pairwise distances d(x_i,y_j) via several metrics. The distance type "intrinsic" corresponds to geodesic distance while "extrinsic" is equivalent to "chordal" distance.

Usage

1
2
3
4
5
6
7
gr.pdist2(
  input1,
  input2,
  type = c("Intrinsic", "Extrinsic", "Asimov", "Binet-Cauchy", "Chordal",
    "Fubini-Study", "Martin", "Procrustes", "Projection", "Spectral"),
  useR = FALSE
)

Arguments

input1

either an array of size (n\times k\times M) or a list of length M whose elements are (n\times k) orthonormal basis (ONB) on Grassmann manifold.

input2

either an array of size (n\times k\times N) or a list of length N whose elements are (n\times k) orthonormal basis (ONB) on Grassmann manifold.

type

type of distance measure. Name of each type is Case Insensitive and hyphen can be omitted.

useR

a logical; TRUE to use R computations while FALSE goes everything in C++.

Value

an (M\times N) matrix of pairwise distances.

Author(s)

Kisung You

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
## generate a dataset with two types of Grassmann elements
#  group1 : first four columns of (8x8) identity matrix + noise
#  group2 : last  four columns of (8x8) identity matrix + noise

mydata1 = list()
mydata2 = list()
sdval   = 0.25
diag8   = diag(8)
for (i in 1:10){
  mydata1[[i]] = qr.Q(qr(diag8[,1:4] + matrix(rnorm(8*4,sd=sdval),ncol=4)))
}
for (i in 1:10){
  mydata2[[i]] = qr.Q(qr(diag8[,5:8] + matrix(rnorm(8*4,sd=sdval),ncol=4)))
}



## compute and visualize distances for all types
#  we will iterate over all measures
alltypes = c("intrinsic","extrinsic","asimov","binetcauchy",
"chordal","fubinistudy","martin","procrustes","projection","spectral")
ntypes   = length(alltypes)

opar <- par(no.readonly=TRUE)
par(mfrow=c(2,5), pty="s")
for (i in 1:ntypes){
  dmat = gr.pdist2(mydata1, mydata2, type=alltypes[i])
  image(dmat, main=alltypes[i])
}
par(opar)

RiemGrassmann documentation built on March 25, 2020, 5:07 p.m.