Join us for
RADAR: AI Edition

smint (version 0.4.2)

ShepFun1: Test functions for/from SHEPPACK

Description

Test functions for/from SHEPPACK

Usage

ShepFun1(x)

Arguments

x
A numeric vector with arbitrary length.

Value

Function's value.

Details

These functions are described in the article cited in the references section. f1(x)=1+2d|d/2ixi| f2(x)=12di|xi0.5| f3(x)=12maxi|xi0.5| f4(x)=i[12|xi0.5|] f5(x)=1c5[i|xi0.5|+i|xi0.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$.

References

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

Examples

Run this code
## 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