set.seed(123)
n <- 16L; nout <- 300L
x <- sort(runif(n))
## let 'xout' contain n + nout points including nodes
xout <- sort(c(x, runif(nout, min = x[1], max = x[n])))
y <- sin(2 * pi * x)
res <- cardinalBasis_ceschino(x, xout = xout, deriv = 0)
matplot(res$x, res$CB, type = "n", main = "Cardinal Basis")
abline(v = x, h = 1.0, col = "gray")
points(x = x, y = rep(0, n), pch = 21, col = "black",
lwd = 2, bg = "white")
matlines(res$x, res$CB, type = "l")
## interpolation error should be fairly small
max(abs(sin(2 * pi * xout) - res$CB \%*\% y))
Run the code above in your browser using DataLab