# NOT RUN {
#nx is number of X points (target) and ny is number of Y points (nontarget)
nx<-20; ny<-4; #try also nx<-1000; ny<-10;
set.seed(1)
Yp<-cbind(runif(ny,0,10),runif(ny,0,10))
Xdt<-runifMT(nx,Yp) #data under CSR in the convex hull of Ypoints
Xdt
summary(Xdt)
plot(Xdt)
dat<-runifMT(nx,Yp)$g #data under CSR in the convex hull of Ypoints
#or use
DTY<-interp::tri.mesh(Yp[,1],Yp[,2],duplicate="remove") #Delaunay triangulation based on Y points
dat<-runifMT(nx,Yp,DTY)$g #data under CSR in the convex hull of Ypoints
Xlim<-range(Yp[,1])
Ylim<-range(Yp[,2])
xd<-Xlim[2]-Xlim[1]
yd<-Ylim[2]-Ylim[1]
#plot of the data in the convex hull of Y points together with the Delaunay triangulation
plot(dat,main=" ", xlab=" ", ylab=" ",xlim=Xlim+xd*c(-.05,.05),ylim=Ylim+yd*c(-.05,.05),type="n")
interp::plot.triSht(DTY, add=TRUE, do.points = TRUE,pch=16,col="blue")
points(dat,pch=".",cex=3)
Yp<-rbind(c(.3,.2),c(.4,.5),c(.14,.15))
runifMT(nx,Yp)
dat.fr<-data.frame(a=Yp)
runifMT(nx,dat.fr)
# }
Run the code above in your browser using DataLab