funsRankOrderTe: Returns the ranks and orders of points in decreasing distance...

funsRankOrderTeR Documentation

Returns the ranks and orders of points in decreasing distance to the edges of the triangle

Description

Two functions: rank.dist2edges.std.tri and order.dist2edges.std.tri.

rank.dist2edges.std.tri finds the ranks of the distances of points in data, Xp, to the edges of the standard equilateral triangle T_e=T((0,0),(1,0),(1/2,\sqrt{3}/2))

dec is a logical argument, default is TRUE, so the ranks are for decreasing distances, if FALSE it will be in increasing distances.

order.dist2edges.std.tri finds the orders of the distances of points in data, Xp, to the edges of T_e. The arguments are as in rank.dist2edges.std.tri.

Usage

rank.dist2edges.std.tri(Xp, dec = TRUE)

order.dist2edges.std.tri(Xp, dec = TRUE)

Arguments

Xp

A set of 2D points representing the data set in which ranking in terms of the distance to the edges of T_e is performed.

dec

A logical argument indicating the how the ranking will be performed. If TRUE, the ranks are for decreasing distances, and if FALSE they will be in increasing distances, default is TRUE.

Value

A list with two elements

distances

Distances from data points to the edges of T_e

dist.rank

The ranks of the data points in decreasing distances to the edges of T_e

Author(s)

Elvan Ceyhan

Examples

## Not run: 
#Examples for rank.dist2edges.std.tri
n<-10
set.seed(1)
Xp<-runif.std.tri(n)$gen.points

dec.dist<-rank.dist2edges.std.tri(Xp)
dec.dist
dec.dist.rank<-dec.dist[[2]]
#the rank of distances to the edges in decreasing order
dec.dist.rank

A<-c(0,0); B<-c(1,0); C<-c(1/2,sqrt(3)/2);
Te<-rbind(A,B,C);

Xlim<-range(Te[,1])
Ylim<-range(Te[,2])
xd<-Xlim[2]-Xlim[1]
yd<-Ylim[2]-Ylim[1]

plot(A,pch=".",xlab="",ylab="",xlim=Xlim+xd*c(-.0,.01),
ylim=Ylim+yd*c(-.01,.01))
polygon(Te)
points(Xp,pch=".")
text(Xp,labels = factor(dec.dist.rank) )

inc.dist<-rank.dist2edges.std.tri(Xp,dec = FALSE)
inc.dist
inc.dist.rank<-inc.dist[[2]]
#the rank of distances to the edges in increasing order
inc.dist.rank
dist<-inc.dist[[1]] #distances to the edges of the std eq. triangle
dist

plot(A,pch=".",xlab="",ylab="",xlim=Xlim,ylim=Ylim)
polygon(Te)
points(Xp,pch=".",xlab="",ylab="", main="",xlim=Xlim+xd*c(-.05,.05),
ylim=Ylim+yd*c(-.05,.05))
text(Xp,labels = factor(inc.dist.rank))

## End(Not run)

## Not run: 
#Examples for order.dist2edges.std.tri
n<-10
set.seed(1)
Xp<-runif.std.tri(n)$gen.points  #try also Xp<-cbind(runif(n),runif(n))

dec.dist<-order.dist2edges.std.tri(Xp)
dec.dist
dec.dist.order<-dec.dist[[2]]
#the order of distances to the edges in decreasing order
dec.dist.order

A<-c(0,0); B<-c(1,0); C<-c(1/2,sqrt(3)/2);
Te<-rbind(A,B,C);

Xlim<-range(Te[,1])
Ylim<-range(Te[,2])
xd<-Xlim[2]-Xlim[1]
yd<-Ylim[2]-Ylim[1]

plot(A,pch=".",xlab="",ylab="",xlim=Xlim+xd*c(-.01,.01),
ylim=Ylim+yd*c(-.01,.01))
polygon(Te)
points(Xp,pch=".")
text(Xp[dec.dist.order,],labels = factor(1:n) )

inc.dist<-order.dist2edges.std.tri(Xp,dec = FALSE)
inc.dist
inc.dist.order<-inc.dist[[2]]
#the order of distances to the edges in increasing order
inc.dist.order
dist<-inc.dist[[1]] #distances to the edges of the std eq. triangle
dist
dist[inc.dist.order] #distances in increasing order

plot(A,pch=".",xlab="",ylab="",xlim=Xlim+xd*c(-.05,.05),
ylim=Ylim+yd*c(-.05,.05))
polygon(Te)
points(Xp,pch=".")
text(Xp[inc.dist.order,],labels = factor(1:n))

## End(Not run)


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