interval.indices.set: Indices of the intervals where the 1D point(s) reside

View source: R/PropEdge1D.R

interval.indices.setR Documentation

Indices of the intervals where the 1D point(s) reside

Description

Returns the indices of intervals for all the points in 1D data set, Xp, as a vector.

Intervals are based on Yp and left end interval is labeled as 1, the next interval as 2, and so on.

Usage

interval.indices.set(Xp, Yp)

Arguments

Xp

A set of 1D points for which the indices of intervals are to be determined.

Yp

A set of 1D points from which intervals are constructed.

Value

The vector of indices of the intervals in which points in the 1D data set, Xp, reside

Author(s)

Elvan Ceyhan

Examples

## Not run: 
a<-0; b<-10; int<-c(a,b)

#nx is number of X points (target) and ny is number of Y points (nontarget)
nx<-15; ny<-4;  #try also nx<-40; ny<-10 or nx<-1000; ny<-10;

set.seed(1)
xf<-(int[2]-int[1])*.1
Xp<-runif(nx,a-xf,b+xf)
Yp<-runif(ny,a,b)  #try also Yp<-runif(ny,a+1,b-1)

ind<-interval.indices.set(Xp,Yp)
ind

jit<-.1
yjit<-runif(nx,-jit,jit)

Xlim<-range(a,b,Xp,Yp)
xd<-Xlim[2]-Xlim[1]

plot(cbind(a,0), xlab=" ", ylab=" ",xlim=Xlim+xd*c(-.05,.05),ylim=3*c(-jit,jit),pch=".")
abline(h=0)
points(Xp, yjit,pch=".",cex=3)
abline(v=Yp,lty=2)
text(Xp,yjit,labels=factor(ind))

## End(Not run)


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