5
Splines and particularly cubic splines are very popular models for interpolation. Historically, a ``spline'' was a common drafting tool, a flexible rod, that was used to help draw smooth curves connecting widely spaced points. The cubic spline curve accomplishes the same result for an interpolation problem. In these notes we describe cubic splines and discuss their use in interpolation and curve fitting. Many texts give the algorithms for determining the spline coefficients, so we do not do that here. Cubic Spline Interpolation Cubic Spline Smoothing About this document ... Cubic Spline Interpolation We start from a table of points for for the function . That makes points and intervals between them. The cubic spline interpolation is a piecewise continuous curve, passing through each of the values in the table. There is a separate cubic polynomial for each interval, each with its own coefficients: together, these polynomial segments are denoted , the spline.

Cubic Spline Interpolation Smoothing

Embed Size (px)

DESCRIPTION

Splines and particularly cubic splines are very popular models for interpolation. Historically, a ``spline'' was a common drafting tool, a flexible rod, that was used to help draw smooth curves connecting widely spaced points. The cubic spline curve accomplishes the same result for an interpolation problem.

Citation preview

Page 1: Cubic Spline Interpolation Smoothing

Splines and particularly cubic splines are very popular models for interpolation. Historically, a ``spline'' was a common drafting tool, a flexible rod, that was used to help draw smooth curves connecting widely spaced points. The cubic spline curve accomplishes the same result for an interpolation problem. In these notes we describe cubic splines and discuss their use in interpolation and curve fitting. Many texts give the algorithms for determining the spline coefficients, so we do not do that here.

Cubic Spline Interpolation Cubic Spline Smoothing About this document ...

Cubic Spline Interpolation

We start from a table of points for for the function .

That makes points and intervals between them. The cubic spline interpolation is a piecewise continuous curve, passing through each of the values in the table. There is a separate cubic polynomial for each interval, each with its own coefficients:

together, these polynomial segments are denoted , the spline.

Since there are intervals and four coefficients for each we require a total of parameters

to define the spline . We need to find independent conditions to fix them. We get two conditions for each interval from the requirement that the cubic polynomial match the values of the table at both ends of the interval:

Notice that these conditions result in a piecewise continuous function.

Page 2: Cubic Spline Interpolation Smoothing

We still need more conditions. Since we would like to make the interpolation as smooth as possible, we require that the first and second derivatives also be continuous:

These conditions apply for , resulting in constraints. So we need two more conditions to completely fix the spline. There are some standard choices left to the user:

1. ``natural''

2. ``clamped''

Other choices are possible if the function is periodic. Which is best depends on the application.

With coefficients and linear conditions it is straightforward to work out the equations that determine them. The conditions can be reduced easily to a tridiagonal system with the

coefficients as the unknowns. Once solved, the remaining coefficients are easily determined. There are many good codes in the public domain.

Cubic splines are popular because they are easy to implement and produce a curve that appears to be seamless. As we have seen, a straight polynomial interpolation of evenly spaced data tends to build in distortions near the edges of the table. Cubic splines avoid this problem, but they are only piecewise continuous, meaning that a sufficiently high derivative (third) is discontinous. So if the application is sensitive to the smoothness of derivatives higher than second, cubic splines may not be the best choice

Cubic Spline Smoothing When interpolating we start from reasonably exact tabulated values and require that the interpolating function pass exactly through the values. In curve fitting we generally start with

a table of experimental data in which the values are imperfectly known, so come with a

confidence interval , and we require that the fitting function come only reasonably close to the data. The table of experimental data consists of three columns

, with the last value specifying the confidence range (commonly one standard deviation).

In cubic spline fitting we relax the requirement that the spline pass exactly through the points and demand only that the spline and its first and second derivatives be continuous:

Page 3: Cubic Spline Interpolation Smoothing

So continuity still leaves degrees of freedom. They are determined by balancing two opposing criteria:

1. The spline must come reasonably close to the data. 2. The spline must have low curvature.

We use a chi square measure to quantify how close the spline comes to the data:

The numerator of each term measures the discrepancy between the spline and the data point.

The denominator provides a weight. The higher the uncertainty the farther we are allowed to miss the data point. If the spline is a good representation of the data, so deviations are only

caused by statistical fluctuations, the average value of each term in is expected to be

about one. For reasonably large the value of is then about .

To quantify the curvature we integrate the square of the second derivative, giving

These constraints are contradictory. Notice that to make the curvature zero, its smallest possible value, the spline would have to have zero curvature -- i.e., a straight line. But that

would probably give us a high value of . On the other hand, we can make equal to zero by having the spline interpolate the points exactly, but that would give a high curvature.

Putting these two constraints together, we require that the cubic spline minimize

The constant determines the tradeoff between the two contradictory criteria. Putting

removes the constraint on altogether and allows the spline to become a straight

Page 4: Cubic Spline Interpolation Smoothing

line. Putting very large puts high emphasis on minimizing , forcing the spline to interpolate without regard to curvature.

Minimizing subject to the continuity requirements leads again to a tridiagonal system that is easily solved to give the coefficients of the cubics.

Making too small allows a high value of . Making it too large forces an unreasonably

small value of . Usually we have to experiment with the choice. The best value results in

in the range .

We should consider ``smoothing'' to be a poor substitute for fitting data to a decent model function that has a fundamental basis. When we fit experimental data to a model function we are actually testing our understanding of nature. When we smooth in order to fit to an arbitrary cubic spline, we are merely parameterizing an observation, but not learning something more fundamental.