Writing B-spline as Piecewise Cubic

邮差的信 提交于 2019-12-23 21:15:07

问题


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.


回答1:


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



来源:https://stackoverflow.com/questions/23235467/writing-b-spline-as-piecewise-cubic

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!