radii {pcds} | R 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 |
y |
A set of |
Value
A list
with three elements
rad |
A |
index.of.clYp |
A |
closest.Yp |
A |
Author(s)
Elvan Ceyhan
See Also
Examples
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)