cardinalBasis_natSpline: Cardinal Basis for natural cubic spline interpolation

Description Usage Arguments Details Value Author(s) Examples

Description

Cardinal Basis for natural cubic spline interpolation.

Usage

1

Arguments

x

Numeric vector of design points.

xout

Numeric vector of new points.

deriv

Integer. Order of derivation. Can be 0, 1 or 2.

Details

This is a simple and raw interface to splinterp Fortran subroutine.

Value

A list with several elements

x

Numeric vector of abscissas at which the basis is evaluated. This is a copy of xout.

CB

Matrix of the Cardinal Basis function values.

deriv

Order of derivation as given on input.

method

Character description of the method involved in the CB determination.

Author(s)

Yves Deville

Examples

 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
26
27
28
29
30
set.seed(123)
n <- 16; nout <- 360
x <- sort(runif(n))

##' ## let 'xout' contain n + nout points including nodes
xout <- sort(c(x, seq(from =  x[1] + 1e-8, to = x[n] - 1e-8, length.out = nout)))
res  <- cardinalBasis_natSpline(x, xout = xout)

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")

## compare with 'splines'
require(splines)
y <- sin(2* pi * x)
sp <- interpSpline(x, y)
test <- rep(NA, 3)
der <- 0:2
names(test) <- nms <- paste("deriv. ", der, sep = "")
for (i in seq(along = der)) {
   resDer <- cardinalBasis_natSpline(x, xout = xout, deriv = der[i])
   test[nms[i]] = max(abs(predict(sp, xout, deriv = der[i])$y - resDer$CB \%*\% y))
}
test
## Lebesgue's function
plot(x = xout, y = apply(res$CB, 1, function(x) sum(abs(x))), type = "l",
     lwd = 2, col = "orangered", main = "Lebesgue\'s function", log = "y",
     xlab = "x", ylab = "L(x)")
points(x = x, y = rep(1, n), pch = 21, col = "black", lwd = 2, bg = "white")

smint documentation built on April 14, 2017, 1:49 p.m.