将B样条写为分段三次 [英] Writing B-spline as Piecewise Cubic
问题描述
我正在使用Scipy的SmoothBivariateSpline类在双变量数据上创建三次B样条.现在,我需要为该样条曲线编写分段多项式表达式.
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.
我的数学背景不是很强,所以我无法编写自己的算法来将SmoothBivariateSpline的t,c,k输出转换为多项式表示.如果可行,您能否提供有关如何实现此目标的指示?我注意到Scipy具有interpolate.ppform,但是我找不到关于它的任何文档-这相关吗?
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?
我正在考虑的一种方法是将样条的域分解为每个结处的区域(总区域为(n-1)^2
,其中n
是结数),然后对网格上的许多点执行三次回归每个区域的样条曲线,以计算每个区域的数据的三次回归.这是有效的方法吗?
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.
推荐答案
B样条可以有效地转换为分段多项式.
B-splines can be converted to piecewise polynomials efficiently.
这可以在具有scipy.interpolate.PPoly.from_spline
的Scipy 0.14.0(要在几个月后发布)中轻松完成.
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
.
从样条线t, c, k
本身计算分段多项式的算法非常简单,因此与此同时,您可以编写自己的函数来计算多项式系数:
https://github.com/scipy/scipy/blob/master/scipy/interpolate/interpolate.py#L938
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
这篇关于将B样条写为分段三次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!