splinebox.spline_curves.Spline.

fit#

Spline.fit(points, boundary_condition='free')#

Fit the provided points with the spline using least squares. For details refer to Data approximation.

Parameters:
pointsnumpy.ndarray

The data points that should be fit.

boundary_conditionstr

Specifies how to hand the ends of open splines. Can be one of the following: ‘free’ (default): No restrictions. ‘clamped’: First derivative is zero at the ends. ‘natural’: Second derivative is zero at the ends.

Examples

>>> spline = splinebox.Spline(M=4, basis_function=splinebox.B3(), closed=False)
>>> print(spline.control_points)
None

The spline is not initialized yet, i.e. the control points haven’t been set yet. We fit the spline to some data to set them.

>>> x = np.linspace(1, 8, 70)
>>> y = np.sin(x)
>>> data = np.stack([x, y], axis=-1)
>>> spline.fit(data)
>>> spline.control_points
array([[-1.333, -5.712],
       [ 1.   ,  2.726],
       [ 3.333, -0.666],
       [ 5.667, -1.477],
       [ 8.   ,  2.811],
       [10.333, -4.283]])

Fit boundary conditions

Fit boundary conditions

Tracking the Undulating Motion of C. elegans

Tracking the Undulating Motion of C. elegans

Dendrite-Centric Coordinate System

Dendrite-Centric Coordinate System

Measure the curvature of a peptide

Measure the curvature of a peptide

Performance Comparison: splinebox vs scipy

Performance Comparison: splinebox vs scipy

Approximating a Noisy Signal

Approximating a Noisy Signal

Comparison splinebox and scipy: contour approximation

Comparison splinebox and scipy: contour approximation