ConstrainedSpline

Tensor-product spline fit through noisy data values.


Declaration

classdef ConstrainedSpline < TensorSpline

Overview

ConstrainedSpline is the noisy-data fitting counterpart to InterpolatingSpline. It fits a tensor-product spline basis to observations sampled on a one-dimensional grid or a rectilinear tensor grid, with optional robust weighting, correlated observation errors, local point constraints, and global shape constraints.

At each iteratively reweighted least-squares step it solves

\[\min_{\xi}\ (y - \mathbf{B}\xi)^{T} W (y - \mathbf{B}\xi)\]

subject to

\[A_{\mathrm{eq}}\xi = b_{\mathrm{eq}}, \qquad A_{\mathrm{ineq}}\xi \le b_{\mathrm{ineq}}.\]

When the distribution model provides correlated errors, the code forms an observation covariance

\[\Sigma_{ij} = \sigma_i \rho(x_i,x_j)\sigma_j\]

and applies the corresponding weighted solve through a matrix factorization rather than explicitly forming \(\Sigma^{-1}\).

Basic usage

Use ConstrainedSpline.fromData(...) for ordinary one-dimensional noisy-data fitting and ConstrainedSpline.fromGriddedValues(...) when the observations lie on a rectilinear tensor grid.

t = linspace(0,1,20)';
x = exp(-20*(t-0.5).^2) + 0.05*randn(size(t));
spline = ConstrainedSpline.fromData(t, x, S=3, constraints=GlobalConstraint.positive());
xFit = spline(t);

Topics

  • Create a constrained tensor spline
    • ConstrainedSpline Create a constrained spline from canonical solved state.
    • fromData Create a constrained spline fit from one-dimensional samples.
    • fromGriddedValues Create a constrained spline fit from values on a rectilinear grid.
  • Inspect fit results
    • dataPoints Observation locations as an N-by-D point matrix.
    • dataValues Observation values as an N-by-1 vector.
    • distribution Error model used while fitting the tensor spline.
    • globalConstraints Global shape constraints used during fitting.
    • gridAxes Grid-axis objects used to define the fitted rectilinear lattice.
    • gridVectors Grid vectors used to define the fitted rectilinear lattice.
    • pointConstraints Local point constraints used during fitting.
  • Analyze the fit
    • smoothingMatrix Return the smoothing matrix that maps observations to fitted values.
  • Choose constraint locations
  • Prepare knot sequences

Developer Topics

These items document internal implementation details and are not part of the primary public API.