radius: The radius of a point from one class with respect to points...

View source: R/AuxGeometry.R

radiusR 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 d-dimensional point for which radius is computed. Radius of p equals to the distance to the closest Y point to p.

Y

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

Value

A list with three elements

rad

Radius value for the point, p defined as \min_{y in Y} d(p,y)

index.of.clYpnt

Index of the closest Y points to the point p

closest.Ypnt

The closest Y point to the point p

Author(s)

Elvan Ceyhan

See Also

radii

Examples

## Not run: 
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)

## End(Not run)


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