moderndid.BSpline#
- class moderndid.BSpline(x=None, internal_knots=None, boundary_knots=None, knot_sequence=None, degree=3, df=None)[source]#
Bases:
SplineBaseB-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.
- degree
int, default=3 The degree of the spline.
- df
int, 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 polynomial degree.
Get internal knots.
Get full knot sequence.
Get spline order (degree + 1).
Get degrees of freedom.
get_x()Get x values.
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 property.
Degree property.
Internal knots property.
Knot sequence property.
Return spline order.
Degrees of freedom property.
X values property.
X index property.