Learn R Programming

pcds (version 0.1.2)

radius: 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 pt with radius=min distance to Y points. That is, for the point pt \(radius= \min_{y \in Y}d(pt,y)\) (i.e., distance from pt to the closest Y point). The point pt and Y points must be of same dimension.

Usage

radius(pt, Y)

Arguments

pt

A \(d\)-dimensional point for which radius is computed. Radius of pt equals to the distance to the closest Y point to pt.

Y

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

Value

A list with three elements

rad

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

index.of.clYpnt

Index of the closest Y points to the point pt

closest.Ypnt

The closest Y point to the point pt

See Also

radii

Examples

Run this code
# 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)
radius(B,Y)
radius(C,Y)

radius(B,C)

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="",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)

dat.fr<-data.frame(a=Y)
radii(A,dat.fr)

# }

Run the code above in your browser using DataLab