Data approximation#
In order to build \(r\), one can either use a pre-defined sequence of control points \(\{ c[k] \}_{k=0,...,M-1}\) or of knots \(\{ n[k] \}_{k=0,...,M-1}\). Alternatively, one can also attempt to retreive the control points that best approximate a set of data points, as in the classical spline approximation setting.
The problem is framed as follows. We consider a set \(\{ p[i] \}_{i=0,...,N-1}\) of \(N\) points to be approximated with the spline model (1) of \(M\) control points. Hereafter, we will assume a periodic spline model, but a similar derivation can easily be done for the non-periodic case.
We obtain an approximation by ensuring that the samples of the spline \(r\) match the data points \(p\), which translates to
Since \(\phi\) is of finite support, we can re-write (1) as
with the basis matrix \(\mathbf{\Phi}\) (size \(N \times M\)), the control point matrix \(\mathbf{C}\) (size \(M \times 1\)), and the data points matrix \(\mathbf{P}\) (size \(N \times 1\)) given by
The control points \(\mathbf{C}\) can then be retrieved by finding the least-square best solution that minimizes
Boundary conditions#
Open splines are padded with additional control points at the ends (Padding). They are located at parameters values \(t = -1, -2, \ldots\) and \(t = M, M+1, \ldots\). Since the data points are only positions on the parameters interval \([0, M-1]\), the additional control points can cause erratic behavior of the spline when fitting noisy data. To control this behaviour, one of the following boundary conditions can be enforced:
clamped: \(r'(0)=0\) and \(r'(M-1)=0\)
natural: \(r''(0)=0\) and \(r''(M-1)=0\)
With out loss of generality, we will describe how to fit a spline with the clamped boundary condition.
The spline can be written as:
where \(p\) is the amount of padding.
The boundary condition allows us to express the first control point as a combination of the other control points:
Note: We assume that \(\Phi'(p) \neq 0\).
Plugging this into equation (7) and grouping the summand by control point yields:
Note: \(\Phi(t+p)\) will be zero for most \(t\) since the support of the basis function \(\Phi\) end in the interval \([p, p+1)\).
We can do the same for the last control point, starting from equation (8):
Because of the way we choose \(p\) and the fact that \(M > 1\), we know that is outside the support of \(\Phi\) and \(\Phi'(M-1+p)=0\). Therefor we get:
Plugging this into equation (8) yields:
Like equation (1), this equation can be written as a matrix-vector multiplication and can be solved using least-squares.