B-spline Interpolation
B-splines are a weighted set of basis functions for polynomial splines.
bspline(vx, vy, u, n)—Returns a vector vs, used by interp, of the following nested arrays: a flag for interp, an array whose columns contain the coefficients of a B-spline of degree n for the data in vx and vy, given the knot values in u, and an array whose columns contain the endpoints of the intervals specified by the knots.
The bspline function can create a linear, quadratic or cubic spline. The resulting spline is different from lspline, pspline or cspline in that bspline joins the polynomial segments at knots that may be different from the locations of the data points themselves.
The following functions accept weights on top of data values, reflecting the level of relative error. The software algorithm calculates a string of knots by using the Durbin-Watson statistic to decide whether to accept or reject spline fits. In this way, statistical B-splines supply a minimal number of knots to reflect all of the data features.
Spline2(vx, vy, n, [vw], [u], [level])—Returns the optimal set of order n B-spline knots to interpolate on data vx and vy, with optional weights vw, optional desired knots u, and an optional reject level. The vector returned becomes the second argument of Binterp.
Binterp(x, b)—Returns a B-spline interpolated y value corresponding to x using the output vector, b, of the Spline2 function, along with the first, second, and third derivatives.
DWS(b)—Returns the Durbin-Watson statistic for the output vector, b, of the Spline2 function.
B-spline interpolation lets you pass a curve through a set of points by taking three adjacent points and constructing a polynomial of degree n passing through those points. These polynomials are then strung together at the knots to form the completed curve. If you have fewer knots than data points, but can still form a reasonable approximation to y, then B-splines are a good method for data compression.
The above B-spline functions are based on Spline2 software, developed by B. J. Thijsse and M. A. Hollanders (this software is documented at http://dutsm183.stm.tudelft.nl/software/software.dita, and is used by permission).
vx, vy are real vectors of data values of the same length.
u is a real vector of knots in ascending order, with n − 1 fewer elements than vx. Knots are those values where the individual B-spline polynomials fit together, unlike other splines, where the knots are forced to be the x values. The first element in u must be smaller or equal than the first element in vx. The last element in u must be greater or equal than the last element in vx.
n is an integer equal to 1, 2, or 3, indicating the degree of the individual piecewise linear (n = 1), quadratic (n = 2), or cubic (n = 3) polynomial fits used in the B-spline.
vw is an optional vector of weights for the spline of the same length as vx and vy.
level is the reject level, expressed as a percentage between 0 and 1 inclusive.
b is a vector generated by Spline2.
x is the value of the independent variable at which you want to evaluate the interpolation curve. For best results, x should be in the range encompassed by the values of vx.
Was this helpful?