radii: The radii of points from one class with respect to points...

View source: R/AuxGeometry.R

radiiR Documentation

The radii of points from one class with respect to points from the other class

Description

Returns the radii of the balls centered at x points where radius of an x point equals to the minimum distance to y points (i.e., distance to the closest y point). That is, for each x point radius= \min_{y \in Y}(d(x,y)). x and y points must be of the same dimension.

Usage

radii(x, y)

Arguments

x

A set of d-dimensional points for which the radii are computed. Radius of an x point equals to the distance to the closest y point.

y

A set of d-dimensional points representing the reference points for the balls. That is, radius of an x point is defined as the minimum distance to the y points.

Value

A list with three elements

rad

A vector whose entries are the radius values for the x points. Radius of an x point equals to the distance to the closest y point

index.of.clYp

A vector of indices of the closest y points to the x points. The i-th entry in this vector is the index of the closest y point to i-th x point.

closest.Yp

A vector of the closest y points to the x points. The i-th entry in this vector or i-th row in the matrix is the closest y point to i-th x point.

Author(s)

Elvan Ceyhan

See Also

radius

Examples

## Not run: 
nx<-10
ny<-5
X<-cbind(runif(nx),runif(nx))
Y<-cbind(runif(ny),runif(ny))
Rad<-radii(X,Y)
Rad
rd<-Rad$rad

Xlim<-range(X[,1]-rd,X[,1]+rd,Y[,1])
Ylim<-range(X[,2]-rd,X[,2]+rd,Y[,2])
xd<-Xlim[2]-Xlim[1]
yd<-Ylim[2]-Ylim[1]

plot(rbind(Y),asp=1,pch=16,col=2,xlab="",ylab="",
main="Circles Centered at Class X Points with \n Radius Equal to the Distance to Closest Y Point",
axes=TRUE, xlim=Xlim+xd*c(-.05,.05),ylim=Ylim+yd*c(-.05,.05))
points(rbind(X))
interp::circles(X[,1],X[,2],Rad$rad,lty=1,lwd=1,col=4)

#For 1D data
nx<-10
ny<-5
Xm<-as.matrix(X)
Ym<-as.matrix(Y)
radii(Xm,Ym)  #this works as Xm and Ym are treated as 1D data sets
#but will give error if radii(X,Y) is used
#as X and Y are treated as vectors (i.e., points)

#For 3D data
nx<-10
ny<-5
X<-cbind(runif(nx),runif(nx),runif(nx))
Y<-cbind(runif(ny),runif(ny),runif(ny))
radii(X,Y)

## End(Not run)


elvanceyhan/pcds documentation built on June 29, 2023, 8:12 a.m.