bundles / scipy latest / scipy / interpolate / _bsplines / BSpline / insert_knot
function
scipy.interpolate._bsplines:BSpline.insert_knot
Signature
def insert_knot ( self , x , m = 1 ) Summary
Insert a new knot at x of multiplicity m.
Extended Summary
Given the knots and coefficients of a B-spline representation, create a new B-spline with a knot inserted m times at point x.
Parameters
x: floatThe position of the new knot
m: int, optionalThe number of times to insert the given knot (its multiplicity). Default is 1.
Returns
spl: `BSpline` objectA new BSpline object with the new knot inserted.
Notes
Based on algorithms from [1] and [2].
In case of a periodic spline (self.extrapolate == "periodic") there must be either at least k interior knots t(j) satisfying t(k+1)<t(j)<=x or at least k interior knots t(j) satisfying x<=t(j)<t(n-k).
This routine is functionally equivalent to scipy.interpolate.insert.
Examples
You can insert knots into a B-spline:import numpy as np from scipy.interpolate import BSpline, make_interp_spline x = np.linspace(0, 10, 5) y = np.sin(x) spl = make_interp_spline(x, y, k=3) spl.t✓
spl_1 = spl.insert_knot(3) spl_1.t✓
spl_2 = spl.insert_knot(8, m=3) spl_2.t✓
See also
Aliases
-
scipy.interpolate.BSpline.insert_knot