ShepFun1(x)
## interpolate 'Shepfun3' for d = 4
d <- 4
GDd <- Grid(nlevels = rep(8, d))
fGrid <- apply_Grid(GDd, ShepFun3)
Xoutd <- matrix(runif(200 * d), ncol = d)
GI <- interp_Grid(X = GDd, Y = fGrid, Xout = Xoutd)
F <- apply(Xoutd, 1, ShepFun3)
max(abs(F - GI))
## 3D plot
require(lattice)
X <- as.data.frame(Grid(nlevels = c("x1" = 30, "x2" = 30)))
df <- data.frame(x1 = numeric(0), x2 = numeric(0),
f = numeric(0), i = numeric(0))
for (i in 1:5) {
f <- apply(X, 1, ShepFuns[[i]])
df <- rbind(df, data.frame(x1 = X$x1, x2 = X$x2, f = f, i = i))
}
pl <- wireframe(f ~ x1 * x2 | i, data = df,
outer = TRUE, shade = FALSE, zlab = "",
screen = list(z = 20, x = -30),
strip = strip.custom(strip.names = c(TRUE),
strip.levels = c(TRUE)),
main = "", horizontal = TRUE, col = "SpringGreen4")
pl
Run the code above in your browser using DataLab