Description Usage Arguments Value See Also Examples
For two points x,y \in \mathcal{M}, two modes of distances are available; intrinsic for geodesic distance
on the manifold and extrinsic for standard norm after equivariant embedding into Euclidean space. This function
differs from rstat.pdist
in that it now computes distances between two sets of data.
1 | rstat.pdist2(input1, input2, type = c("intrinsic", "extrinsic"))
|
input1 |
a S3 object of |
input2 |
a S3 object of |
type |
type of distance, either |
an (N\times M) matrix of pairwise distances.
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 | ### Generate 100 data points on Sphere S^2.
# 50 points from near (0,0,1), and
# 50 points from near (0,0,-1)
ndata = 50
theta = seq(from=-0.99,to=0.99,length.out=ndata)*pi
tmpx = cos(theta)
tmpy = sin(theta)
### Wrap those as 'riemdata' class
data1 = list()
data2 = list()
for (i in 1:ndata){
tgt1 = c(tmpx[i],tmpy[i],1) + stats::rnorm(3,sd=0.1)
tgt2 = c(tmpx[i],tmpy[i],-1) + stats::rnorm(3,sd=0.1)
data1[[i]] = tgt1/sqrt(sum(tgt1^2)) # projection near (0,0,1)
data2[[i]] = tgt2/sqrt(sum(tgt2^2)) # (0,0,-1)
}
spdata1 = RiemBase::riemfactory(data1, name="sphere")
spdata2 = RiemBase::riemfactory(data2, name="sphere")
### Compute Two Types of Distances and Visualize
dist.int = rstat.pdist2(spdata1, spdata2, type="intrinsic")
dist.ext = rstat.pdist2(spdata1, spdata2, type="extrinsic")
### Visualize
opar <- par(no.readonly=TRUE)
par(mfrow=c(1,2))
image(dist.int, main="intrinsic")
image(dist.ext, main="extrinsic")
par(opar)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.