Skip to content
All library documents

Fitting Smooth Piecewise Curves with Two-Dimensional Splines

Article Quant Q&A · Author: d3rk_knight

Summary

The document outlines how spline methods can fit functions defined over separate regions while enforcing continuity and differentiability at their boundaries. It first describes univariate splines, where each interval has a polynomial segment and neighboring segments are constrained to match in value and derivatives at shared nodes. Boundary assumptions are needed to determine the remaining parameters.

It then extends the idea to bivariate splines, representing the surface with polynomial segments over rectangular regions. Each segment’s coefficients are determined from data and smoothness conditions across region boundaries. The discussion is conceptual rather than a complete fitting procedure: it does not specify an estimation objective, regularization, knot selection, or boundary conditions for the two-dimensional case. The parameter count grows quickly with polynomial order, so the method requires sufficient observations and additional modeling choices.

Key ideas

  • Piecewise polynomial splines can enforce matching values and derivatives at shared boundaries.
  • A univariate spline fit needs boundary assumptions to resolve remaining coefficients.
  • A bivariate spline assigns a polynomial surface segment to each rectangular region.
  • Higher polynomial order increases the number of coefficients and smoothness constraints.
  • The outline does not provide a complete estimation or boundary-condition procedure for the bivariate case.

Tags

Full text
# Curve fitting under different regions and stitching


# Curve fitting under different regions and stitching












Is there a way to fit a 2D curve under the following conditions:

- The curve is defined by 2 functions for x>a, and x<a

- Prefer a fit that is continuous and differentiable at x=a

## Answer by Kermittfrog (score 6)

https://quant.stackexchange.com/a/61893

I hope I understood you correctly and that the following thoughts help you a bit.

Reference point: Univariate curve fitting using splines

With a univariate function $f(x)$ you can perform 1D spline interpolation and require for each (inner) $x_i$-node that: $$ \begin{align} \left.f_{i-1}(x)\right|_{x=x_i}&=\left.f_i(x)\right|_{x=x_i} \quad \mathrm{continuity}\\ \left.\frac{\partial ^k f_{i-1}(x)}{\partial x^k}\right|_{x=x_i}&=\left.\frac{\partial ^k f_{i}(x)}{\partial x^k}\right|_{x=x_i} \quad k\mathrm{th \ order \ differentiability}\\ \end{align} $$

And the $K$th order 1D-spline function is identified by

$$f_i(x)=\sum_{j=0}^K\beta_{i,j}x^j \quad \mathrm{for} \quad x_i\leq x<x_{i+1} $$

For an $K-1$th-order spline you get $K$ degrees of freedom per function. Say you have a total of $N$ test points $\{x_i,y_i\}_{i=0\ldots{N-1}}$. This nets you a total of $N-1$ functions to fit and hence $K\times(N-1)$ parameters. Say you select a cubic spline ($K=3$, four degrees of freedom per function), then you could, for example, produce a spline such that $$ \begin{align} \beta_{i-1,0}+\beta_{i-1,1}x_i+\beta_{i-1,2}x_i^2+\beta_{i-1,3}x_i^3&=\beta_{i,0}+\beta_{i,1}x_i+\beta_{i,2}x_i^2+\beta_{i,3}x_i^3 \quad \mathrm{equality}\\ \beta_{i-1,1}+2\beta_{i-1,2}x_i+3\beta_{i-1,3}x_i^2&=\beta_{i,1}+2\beta_{i,2}x_i+3\beta_{i,3}x_i^2 \quad \mathrm{f'}\\ 2\beta_{i-1,2}+6\beta_{i-1,3}x_i&=2\beta_{i,2}+6\beta_{i,3}x_i \quad \mathrm{f''}\\ \beta_{i-1,3}&=\beta_{i,3} \quad \mathrm{f'''} \end{align} $$ holds at all (inner) nodes. In total, you have thus identified $N + 3(N-2)$ of your parameters. Adding an assumption on the behavior of $f_0‘(x_0)$ and $f_{N-1}^‘(x_{N-1})$ usually yields the remaining parameters.

Your case: Bivariate extension

In the bivariate spline case, each point is now bounde by a surface segment (surrounded by 4 test points):

$$ \begin{align} x_{i-1}\leq x < x_i, y_{j-1}\leq y < y_j \end{align} $$ and the spline function is now commonly given by:

$$ f_{i,j}(x,y)=\sum_{k=0}^K\sum_{l=0}^K\beta_{i,j,k,l}x^ky^l $$

As you can see, a $K$th order 2D-spline requires (canonically) $(K+1)^2$ parameters per segment. Hence, we need more test points to enter the spline function, and we have a quadratic increase in conditions (continuity, differentiability...). This may be a good starting point for your endeavour.

Shown in full with attribution under the source's licence. Licence: CC BY-SA 4.0 (Stack Exchange)

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.