# example code for getting a 2d isotonic 
# regression estimator from simulated data
# and plotting it using the R function persp

x1=runif(100);x2=runif(100)
xmatrix=cbind(x1,x2)
ys=x1+exp(x2)+rnorm(100)/4

x1max=max(x1);x2max=max(x2)
x1min=min(x1);x2min=min(x2)

xp1=(trunc(0:399/20))/19*(x1max-x1min)+x1min
xp2=(0:399-19*20*xp1)/19*(x2max-x2min)+x2min
xpred=cbind(xp1,xp2)
x1g=0:19/19;x2g=x1g

ans=multiso(xmatrix,ys,xpred,FALSE)

surf=matrix(ans$thetap,nrow=20,ncol=20)
persp(x1g,x2g,surf,theta=-30,tick="detailed")