3

I'm using Scipy's SmoothBivariateSpline class to create a cubic B-spline on bivariate data. I now need to write the piecewise polynomial expression for this spline curve.

My mathematical background isn't very strong, so I wasn't able to write my own algorithm for transforming from the t, c, k output of the SmoothBivariateSpline to a polynomial representation. If this is feasible, can you provide pointers on how to approach this? I noticed that Scipy has interpolate.ppform, but I can't find any docs for it - is this relevant?

One method I was considering was breaking down the domain of the spline into regions at each knot (with (n-1)^2 total regions, where n is the number of knots), then performing a cubic regression on many points on the spline curve in each region in order to calculate a cubic regression to the data for every region. Is this a valid approach?

The former method seems much more rigorous, so I'd prefer to use that one, but the latter is also acceptable.

Shivam Sarodia
  • 417
  • 1
  • 4
  • 20

1 Answers1

5

B-splines can be converted to piecewise polynomials efficiently.

This can be easily done in Scipy 0.14.0 (to be released in a couple of months) which has scipy.interpolate.PPoly.from_spline.

The algorithm of computing piecewise polynomials from the spline t, c, k itself is very simple, so in the meantime you can write your own function that computes the polynomial coefficients: https://github.com/scipy/scipy/blob/master/scipy/interpolate/interpolate.py#L938

pv.
  • 33,875
  • 8
  • 55
  • 49
  • OK, I'll write my own function for this task. It looks like from_spline simply finds the Taylor polynomial, centered at a knot. In my case, since I have a bivariate spline, would I calculate the two-dimensional Taylor function instead? Also, what would be the breakpoints? – Shivam Sarodia Apr 27 '14 at 05:13
  • @Draksis: a detailed answer to a similar question is posted at http://stackoverflow.com/questions/22488637/getting-spline-equation-from-univariatespline-object/25330648#25330648. The answer provides a function for manually evaluating the 1D B-spline knots and coefficients, giving some insight into what they mean. Perhaps you can generate something similar by expanding on the 1D case provided. – nzh Aug 15 '14 at 17:10