## B-Splines and Smoothing Splines

In this toolbox, the definition of a B-spline with knots *t _{j}*, ...,

*t*

_{j+k}is given by

$${B}_{j,k}(x)=B\left(x|{t}_{j},\mathrm{...},{t}_{j+k}\right)=\left({t}_{j+k}-{t}_{j}\right)\left[{t}_{j},\mathrm{...},{t}_{j+k}\right]{(x-\cdot )}_{+}^{k-1}.$$

This is only one of several reasonable normalizations of the B-spline. It is chosen so that

$$\sum _{j=1}^{n}{B}_{j,k}(x)}=1,\text{\hspace{1em}}{t}_{k}\le x\le {t}_{n+1}.$$

But, instead of trying to understand the above formula for the B-spline, look at the
reference pages for the GUI `bspligui`

for some of the basic properties of
the B-spline, and use that GUI to gain some firsthand experience with this intriguing
function. Its most important property for the purposes of this toolbox is also the reason
the letter B is in its name:

*Every space of (univariate) piecewise-polynomials of a given order has a
**Basis consisting of *B*-splines (hence the
“B” in B-spline).*

### B-Spline Properties

Because *B _{j,k}* is nonzero
only on the interval (

*t*..

_{j}*t*

_{j}_{+}

*), the linear system for the B-spline coefficients of the spline to be determined, by interpolation or least squares approximation, or even as the approximate solution of some differential equation, is*

_{k}*banded*, making the solving of that linear system particularly easy. For example, to construct a spline

*s*of order

*k*with knot sequence

*t*

_{1}≤

*t*

_{2 }≤··· ≤

*t*

_{n}_{+}

*so that*

_{k}*s*(

*x*)=

_{i}*y*for

_{i}*i*=1, ...,

*n*, use the linear system

$$\begin{array}{cc}{\displaystyle \sum _{j=1}^{n}{B}_{j,k}}\left({x}_{i}\right){a}_{j}={y}_{i}& i=1:n\end{array}$$

for the unknown B-spline coefficients *a _{j}* in
which each equation has at most

*k*nonzero entries.

Also, many theoretical facts concerning splines are most easily
stated and/or proved in terms of B-splines. For example, it is possible
to match arbitrary data at sites $${x}_{1}<\cdots <{x}_{n}$$ uniquely
by a spline of order *k* with knot sequence (t_{1},
..., t_{n+k}) if and only
if *B _{j,k}(x_{j})≠0* for
all

*j*(Schoenberg-Whitney Conditions). Computations with B-splines are facilitated by stable

*recurrence relations*

$${B}_{j,k}\left(x\right)=\frac{x-{t}_{j}}{{t}_{j+k-1}-{t}_{j}}{B}_{j,k-1}\left(x\right)+\frac{{t}_{j+k}-x}{{t}_{j+k}-{t}_{j+1}}{B}_{j+1,k-1}\left(x\right)$$

which are also of help in the conversion from
B-form to ppform. The **dual functional **

$${a}_{j}\left(s\right):={\displaystyle \sum _{i<k}{\left(-D\right)}^{k-i-1}{\Psi}_{j}\left(\tau \right)}{D}^{i}s\left(\tau \right)$$

provides a useful expression for the *j*th B-spline coefficient of the spline
*s* in terms of its value and derivatives at an arbitrary site τ
between *t _{j}* and

*t*, and with ψ

_{j+k}*(*

_{j}*t*):=(

*t*

_{j+1}*–t*)··· (

*t*

_{j+k–1}*–t*)/(

*k*–1)!. It can be used to show that

*a*(

_{j}*s*) is closely related to

*s*on the interval [

*t*], and seems the most efficient means for converting from ppform to B-form.

_{j}..t_{j+k}### Variational Approach and Smoothing Splines

The above *constructive* approach is
not the only avenue to splines. In the *variational* approach, a spline is obtained as a *best interpolant*,
e.g., as the function with smallest *m*th derivative
among all those matching prescribed function values at certain sites.
As it turns out, among the many such splines available, only those
that are piecewise-polynomials or, perhaps, piecewise-exponentials
have found much use. Of particular practical interest is the *smoothing spline* *s* = *s** _{p}* which,
for given data (

*x*) with

_{i},y_{i}*x*∊[

*a..b*], all

*i*, and given corresponding positive weights

*w*, and for given

_{i}*smoothing parameter*

*p*, minimizes

$$p{\displaystyle \sum _{i}{w}_{i}}{\left|{y}_{i}-f\left({x}_{i}\right)\right|}^{2}+\left(1-p\right){\displaystyle {\int}_{a}^{b}{\left|{D}^{m}f(t)\right|}^{2}dt}$$

over all functions *f* with *m* derivatives.
It turns out that the smoothing spline *s* is a spline
of order *2m* with a break at every data site. The
smoothing parameter, *p*, is chosen artfully to strike
the right balance between wanting the *error measure*

$$E\left(s\right)={\displaystyle \sum _{i}{w}_{i}{\left|{y}_{i}-s\left({x}_{i}\right)\right|}^{2}}$$

small and wanting the *roughness measure*

$$F\left({D}^{m}s\right)={\displaystyle {\int}_{a}^{b}{\left|{D}^{m}s\left(t\right)\right|}^{2}dt}$$

small. The hope is that *s* contains as much
of the information, and as little of the supposed noise, in the data as possible. One approach to this (used
in `spaps`

) is to make *F(D ^{m}f)* as
small as possible subject to the condition that

*E(f)*be no bigger than a prescribed tolerance. For computational reasons,

`spaps`

uses
the (equivalent) smoothing parameter ρ=p/(1–p),
i.e., minimizes ρ*E*(

*f*) +

*F*(

*D*). Also, it is useful at times to use the more flexible roughness measure

^{m}f$$F\left({D}^{m}s\right)={\displaystyle {\int}_{a}^{b}\lambda \left(t\right){\left|{D}^{m}s(t)\right|}^{2}dt}$$

with λ a suitable positive weight function.