Description Usage Arguments Value Examples
Unlike rbase.pdist
, rbase.pdist2
takes two sets of data X=\{ x_i \}_{i=1}^m and Y=\{ y_j \}_{j=1}^m
and compute mn number of pairwise distances for all i and j.
1 | rbase.pdist2(input1, input2, parallel = FALSE)
|
input1 |
a S3 object of |
input2 |
a S3 object of |
parallel |
a flag for enabling parallel computation. |
an (m\times n) matrix of pairwise distances.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | ### Generate 10 2-frames in R^4 : as grassmann points
ndata = 10
data = array(0,c(4,2,ndata))
for (i in 1:ndata){
tgt = matrix(rnorm(4*4),nrow=4)
data[,,i] = qr.Q(qr(tgt))[,1:2]
}
gdata = riemfactory(data, name="grassmann")
## Compute Pairwise Distances using pdist and pdist2
A = rbase.pdist(gdata)
B = rbase.pdist2(gdata,gdata)
## Visual Comparison in Two Cases
opar = par(no.readonly=TRUE)
par(mfrow=c(1,2), pty="s")
image(A, col=gray((0:100)/100), main="pdist")
image(B, col=gray((0:100)/100), main="pdist2")
par(opar)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.