简体   繁体   English

将B样条写成分段立方

[英]Writing B-spline as Piecewise Cubic

I'm using Scipy's SmoothBivariateSpline class to create a cubic B-spline on bivariate data. 我正在使用Scipy的SmoothBivariateSpline类在双变量数据上创建一个三次B样条。 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. 我的数学背景不是很强,所以我无法编写自己的算法来将SmoothBivariateSpline的t,c,k输出转换为多项式表示。 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? 我注意到Scipy有interpolate.ppform,但我找不到任何文档 - 这是相关的吗?

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. 我正在考虑的一种方法是将样条的域分解为每个结的区域(总共有(n-1)^2个区域,其中n是结的数量),然后对样条上的许多点执行三次回归每个区域中的曲线,以计算每个区域的数据的立方回归。 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-splines can be converted to piecewise polynomials efficiently. B样条可以有效地转换为分段多项式。

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 . 这可以在Scipy 0.14.0(将在几个月内发布)中轻松完成,该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 从样条t, c, k本身计算分段多项式的算法非常简单,因此在此期间你可以编写自己的函数来计算多项式系数: https//github.com/scipy/scipy/blob/master /scipy/interpolate/interpolate.py#L938

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM