{ } Raw JSON

bundles / scipy 1.17.1 / scipy / interpolate / _bsplines / BSpline / insert_knot

function

scipy.interpolate._bsplines:BSpline.insert_knot

source: /scipy/interpolate/_bsplines.py :899

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 : float

The position of the new knot

m : int, optional

The number of times to insert the given knot (its multiplicity). Default is 1.

Returns

spl : `BSpline` object

A 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
Insert a single knot
spl_1 = spl.insert_knot(3)
spl_1.t
Insert a multiple knot
spl_2 = spl.insert_knot(8, m=3)
spl_2.t

See also

scipy.interpolate.insert

Aliases

  • scipy.interpolate.BSpline.insert_knot