moderndid.BSpline#

class moderndid.BSpline(x=None, internal_knots=None, boundary_knots=None, knot_sequence=None, degree=3, df=None)[source]#

Bases: SplineBase

B-spline basis functions.

The B-spline basis of degree \(d\) is defined by a sequence of knots \(t_0, t_1, \ldots, t_{m}\). The basis functions \(B_{i,d}(x)\) are defined recursively as

\[B_{i,0}(x) = 1 \quad \text{if } t_i \le x < t_{i+1}, \text{ and } 0 \text{ otherwise,}\]
\[B_{i,d}(x) = \frac{x - t_i}{t_{i+d} - t_i} B_{i,d-1}(x) + \frac{t_{i+d+1} - x}{t_{i+d+1} - t_{i+1}} B_{i+1,d-1}(x).\]
Parameters:
xarray_like, optional

The values at which to evaluate the basis functions.

internal_knotsarray_like, optional

The internal knots of the spline.

boundary_knotsarray_like, optional

The boundary knots of the spline. If not provided, they are inferred from the range of \(x\).

knot_sequencearray_like, optional

A full knot sequence. If provided, it overrides other knot specifications.

degreeint, default=3

The degree of the spline.

dfint, optional

The degrees of freedom of the spline. This determines the number of internal knots if they are not provided.

Methods

basis([complete_basis])

Compute B-spline basis functions.

derivative([derivs, complete_basis])

Compute derivatives of B-spline basis functions.

get_boundary_knots()

Get boundary knots.

get_degree()

Get polynomial degree.

get_internal_knots()

Get internal knots.

get_knot_sequence()

Get full knot sequence.

get_order()

Get spline order (degree + 1).

get_spline_df()

Get degrees of freedom.

get_x()

Get x values.

get_x_index()

Get x indices relative to knot sequence.

integral([complete_basis])

Compute integrals of B-spline basis functions.

set_boundary_knots(knots)

Set boundary knots and update the spline state.

set_degree(degree)

Set polynomial degree.

set_internal_knots(knots)

Set internal knots and update the spline state.

set_knot_sequence(seq)

Set knot sequence and update dependent properties.

set_order(order)

Set spline order.

set_x(x)

Set x values.

Attributes

boundary_knots

Boundary knots property.

degree

Degree property.

internal_knots

Internal knots property.

knot_sequence

Knot sequence property.

order

Return spline order.

spline_df

Degrees of freedom property.

x

X values property.

x_index

X index property.