radius {pcds} | R Documentation |
The radius of a point from one class with respect to points from the other class
Description
Returns the radius for the ball centered
at point p
with radius=min distance to Y
points.
That is, for the point p
radius= \min_{y \in Y}d(p,y)
(i.e., distance from p
to the closest Y
point).
The point p
and Y
points must be of same dimension.
Usage
radius(p, Y)
Arguments
p |
A |
Y |
A set of |
Value
A list
with three elements
rad |
Radius value for the point, |
index.of.clYpnt |
Index of the closest |
closest.Ypnt |
The closest |
Author(s)
Elvan Ceyhan
See Also
Examples
A<-c(1,1); B<-c(2,0); C<-c(1.5,2);
ny<-10
Y<-cbind(runif(ny),runif(ny))
radius(A,Y)
nx<-10
X<-cbind(runif(nx),runif(nx))
rad<-rep(0,nx)
for (i in 1:nx)
rad[i]<-radius(X[i,],Y)$rad
Xlim<-range(X[,1]-rad,X[,1]+rad,Y[,1])
Ylim<-range(X[,2]-rad,X[,2]+rad,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,lty=1,lwd=1,col=4)
#For 1D data
ny<-5
Y<-runif(ny)
Ym = as.matrix(Y)
radius(1,Ym) #this works as Y is treated as 1D data sets
#but will give error if radius(1,Y) is used
#as Y is treated as a vector (i.e., points)
#For 3D data
ny<-5
X<-runif(3)
Y<-cbind(runif(ny),runif(ny),runif(ny))
radius(X,Y)
[Package pcds version 0.1.8 Index]