Basis Splines¶ ↑
This chapter describes functions for the computation of smoothing basis splines (Bsplines). This is only for GSL1.9 or later.
Overview¶ ↑
Bsplines are commonly used as basis functions to fit smoothing curves to large data sets. To do this, the abscissa axis is broken up into some number of intervals, where the endpoints of each interval are called breakpoints. These breakpoints are then converted to knots by imposing various continuity and smoothness conditions at each interface. Given a nondecreasing knot vector t = {t_0, t_1, dots, t_{n+k1, the n basis splines of order k are defined by for i = 0, dots, n1. The common case of cubic Bsplines is given by k = 4. The above recurrence relation can be evaluated in a numerically stable way by the de Boor algorithm.
If we define appropriate knots on an interval [a,b] then the Bspline basis functions form a complete set on that interval. Therefore we can expand a smoothing function as given enough (x_j, f(x_j)) data pairs. The c_i can be readily obtained from a leastsquares fit.
Initializing the Bsplines solver¶ ↑

GSL::BSpline.alloc(k, nbreak)
This method creates a workspace for computing Bsplines of order
k
. The number of breakpoints is given bynbreak
. This leads ton = nbreak + k  2
basis functions. Cubic Bsplines are specified byk = 4
. The size of the workspace isO(5k + nbreak)
.
Constructing the knots vector¶ ↑

GSL::BSpline#knots(breakpts)
This method computes the knots associated with the given breakpoints
breakpts
and returns the knots as aGSL::Vector::View
object.

GSL::BSpline#knots_uniform(a, b)
This method assumes uniformly spaced breakpoints on [
a,b
] and constructs the corresponding knot vector using the previously specifiednbreak
parameter.
Evaluation of Bsplines¶ ↑

GSL::BSpline#eval(x[, B])
This method evaluates all Bspline basis functions at the position
x
and stores them inB
(if given), so that the ith element ofB
isB_i(x)
.B
must be of lengthn = nbreak + k  2
. IfB
is not given, a newly created vector is returned.It is far more efficient to compute all of the basis functions at once than to compute them individually, due to the nature of the defining recurrence relation.