scipy.interpolate.BSpline.from_power_basis#
- classmethod BSpline.from_power_basis(pp, bc_type='not-a-knot')[source]#
Construct a polynomial in the B-spline basis from a piecewise polynomial in the power basis.
For now, accepts
CubicSpline
instances only.- Parameters:
- ppCubicSpline
A piecewise polynomial in the power basis, as created by
CubicSpline
- bc_typestring, optional
Boundary condition type as in
CubicSpline
: one of thenot-a-knot
,natural
,clamped
, orperiodic
. Necessary for construction an instance ofBSpline
class. Default isnot-a-knot
.
- Returns:
- bBSpline object
A new instance representing the initial polynomial in the B-spline basis.
Notes
New in version 1.8.0.
Accepts only
CubicSpline
instances for now.The algorithm follows from differentiation the Marsdenâ€™s identity [1]: each of coefficients of spline interpolation function in the B-spline basis is computed as follows:
\[c_j = \sum_{m=0}^{k} \frac{(k-m)!}{k!} c_{m,i} (-1)^{k-m} D^m p_{j,k}(x_i)\]\(c_{m, i}\) - a coefficient of CubicSpline, \(D^m p_{j, k}(x_i)\) - an m-th defivative of a dual polynomial in \(x_i\).
k
always equals 3 for now.First
n - 2
coefficients are computed in \(x_i = x_j\), e.g.\[c_1 = \sum_{m=0}^{k} \frac{(k-1)!}{k!} c_{m,1} D^m p_{j,3}(x_1)\]Last
nod + 2
coefficients are computed inx[-2]
,nod
- number of derivatives at the ends.For example, consider \(x = [0, 1, 2, 3, 4]\), \(y = [1, 1, 1, 1, 1]\) and bc_type =
natural
The coefficients of CubicSpline in the power basis:
\([[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [1, 1, 1, 1, 1]]\)
The knot vector: \(t = [0, 0, 0, 0, 1, 2, 3, 4, 4, 4, 4]\)
In this case
\[c_j = \frac{0!}{k!} c_{3, i} k! = c_{3, i} = 1,~j = 0, ..., 6\]References
[1]Tom Lyche and Knut Morken, Spline Methods, 2005, Section 3.1.2