Description Usage Arguments Details Value Note References Examples
Test functions for/from SHEPPACK
1 | ShepFun1(x)
|
x |
A numeric vector with arbitrary length. |
These functions are described in the article cited in the references section.
f1(x) = 1 + (2/d) | (d/2) - sum_i x_i |
f2(x) = 1 - (2/d) sum_i |x_i - 0.5 |
f3(x) = 1 - 2 max_{i} |x_i - 0.5 |
f4(x) = prod_i [ 1 - 2 | x_i - 0.5 | ]
f5(x) = 1 - c_5 [ sum_i |x_i - 0.5 | + prod_i | x_i - 0.5 | ]
where c_5 = d/2 + (0.5)^d, and all sums or products are for i=1 to d. All these functions are defined on [0,\,1]^d and take values in [0,1]. The four functions f_i for i > 1 have an unique maximum located at xStar with all coordinates xStar[j] = 0.5 and f_i(xStar) = 1.
Function's value.
These functions are also exported as elements of the
ShepFuns
list.
W.I. Thacker, J. Zhang, L.T. Watson, J.B. Birch, M.A. Iyer and M.W. Berry (2010). Algorithm 905: SHEPPACK: Modified Shepard Algorithm for Interpolation of Scattered Multivariate Data ACM Trans. on Math. Software (TOMS) Vol. 37, n. 3. link
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | ## 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
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.