## Produces a 2d step function
set.seed(79)
n <- 100; p <- 2
## Pick some random knots
x <- matrix(runif(n * p, min = -2.5, max = 2.5), nrow = n, ncol = p)
obj = multistep(rep(0.1, (n-1)*p), x)
x2 <- matrix(runif(n * p, min = -2.5, max = 2.5), nrow = n, ncol = p)
obj * x2 - obj*x
image( outer(-50:50/10, -50:50/10, function(x,y) obj*c(x,y)))
Run the code above in your browser using DataLab