Interpolating B-spline of arbitrary degree, parametrised in x.
The spline passes through all data points. Default knots are the ones of scipy.interpolate.make_interp_spline: not-a-knot for odd degree (de Boor) and midpoints between data points for even degree. The spline is evaluated with de Boor's algorithm, outside the data range the end polynomial is continued.
Interpolating B-spline of arbitrary degree, parametrised in x. The spline passes through all data points. Default knots are the ones of `scipy.interpolate.make_interp_spline`: not-a-knot for odd degree (de Boor) and midpoints between data points for even degree. The spline is evaluated with de Boor's algorithm, outside the data range the end polynomial is continued.
(b-spline xs ys)(b-spline xs ys {:keys [degree knots]})Creates an interpolating B-spline of a given degree, parametrised in x.
The spline passes through all data points and equals scipy.interpolate.make_interp_spline(x, y, k=degree) (default knots) up to rounding errors. It replaces the former control polygon form: xs are the nodes of the interpolation and not the control points.
Parameters:
xs (sequence of numbers): nodes, strictly increasing and finiteys (sequence of numbers): values, same length as xs; NaN or infinite values give NaN resultsopts (map, optional):
:degree (long, default: 3): degree of the spline, an integer >= 1; 1 is the linear interpolation, 3 the cubic spline:knots (sequence of numbers, default: nil): full knot vector of count xs + degree + 1 non-decreasing values; nil selects the default knotsDefault knots: for an odd degree the not-a-knot condition (de Boor): the data points without the (degree + 1) / 2 nearest to each end; for an even degree the midpoints between data points without the degree / 2 nearest to each end (as scipy). The end points are repeated degree + 1 times. With these knots the cubic spline is the not-a-knot spline, so for count xs = degree + 1 it is the interpolating polynomial.
Custom :knots have to be non-decreasing and finite, the interval between the knots with indices degree and count xs has to contain all nodes and the Schoenberg-Whitney conditions have to be satisfied, otherwise the spline would not exist. The spline is defined by the knots on that interval and it is continued by the end polynomials outside of it.
Returns a function of one argument x which returns the value of the spline. Outside of the data range the end polynomial is continued (no clamping), NaN gives NaN. The result is a polynomial of degree degree on every knot interval and it is continuously differentiable degree - 1 times where knots are simple.
Throws ex-info (:type :invalid-input) when the number of points is smaller than degree + 1, when xs and ys have different lengths, when xs is not finite or not strictly increasing, when :degree is not an integer >= 1 or when the knots are invalid.
See also fastmath.interpolation/interpolation, fastmath.interpolation.cubic/cubic.
Creates an interpolating B-spline of a given degree, parametrised in x.
The spline passes through all data points and equals `scipy.interpolate.make_interp_spline(x, y, k=degree)` (default knots) up to rounding errors. It replaces the former control polygon form: `xs` are the nodes of the interpolation and not the control points.
Parameters:
- `xs` (sequence of numbers): nodes, strictly increasing and finite
- `ys` (sequence of numbers): values, same length as `xs`; `NaN` or infinite values give `NaN` results
- `opts` (map, optional):
- `:degree` (long, default: `3`): degree of the spline, an integer `>= 1`; `1` is the linear interpolation, `3` the cubic spline
- `:knots` (sequence of numbers, default: `nil`): full knot vector of `count xs + degree + 1` non-decreasing values; `nil` selects the default knots
Default knots: for an odd degree the not-a-knot condition (de Boor): the data points without the `(degree + 1) / 2` nearest to each end; for an even degree the midpoints between data points without the `degree / 2` nearest to each end (as scipy). The end points are repeated `degree + 1` times. With these knots the cubic spline is the not-a-knot spline, so for `count xs = degree + 1` it is the interpolating polynomial.
Custom `:knots` have to be non-decreasing and finite, the interval between the knots with indices `degree` and `count xs` has to contain all nodes and the Schoenberg-Whitney conditions have to be satisfied, otherwise the spline would not exist. The spline is defined by the knots on that interval and it is continued by the end polynomials outside of it.
Returns a function of one argument `x` which returns the value of the spline. Outside of the data range the end polynomial is continued (no clamping), `NaN` gives `NaN`. The result is a polynomial of degree `degree` on every knot interval and it is continuously differentiable `degree - 1` times where knots are simple.
Throws `ex-info` (`:type :invalid-input`) when the number of points is smaller than `degree + 1`, when `xs` and `ys` have different lengths, when `xs` is not finite or not strictly increasing, when `:degree` is not an integer `>= 1` or when the knots are invalid.
See also [[fastmath.interpolation/interpolation]], [[fastmath.interpolation.cubic/cubic]].cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |