(cubic xs ys)Creates a 1D natural cubic spline interpolator.
The spline is piecewise cubic, passes through all data points and has continuous first and second derivatives. The natural boundary conditions set the second derivative to zero at both end points.
Parameters:
xs (sequence of numbers): nodes, finite and strictly increasing; at least 2 points.ys (sequence of numbers): values, the same length as xs.Returns a function f such that (f x) returns the interpolated double value at x. It equals scipy.interpolate.CubicSpline with bc_type='natural'. Outside the domain the cubic of the first or the last interval is continued (extrapolation, like scipy; the second derivative is not zero there, so the extrapolation is cubic, not linear). With 2 points the spline is the straight line.
Throws ex-info (with :type :invalid-input, :method :cubic and a :property) when the lengths differ, there are fewer than 2 points, xs contains NaN or an infinity, or xs is not strictly increasing (unsorted or duplicated).
See also fastmath.interpolation.linear/linear, fastmath.interpolation.monotone/monotone, cubic-2d.
Creates a 1D natural cubic spline interpolator. The spline is piecewise cubic, passes through all data points and has continuous first and second derivatives. The natural boundary conditions set the second derivative to zero at both end points. Parameters: - `xs` (sequence of numbers): nodes, finite and strictly increasing; at least 2 points. - `ys` (sequence of numbers): values, the same length as `xs`. Returns a function `f` such that `(f x)` returns the interpolated `double` value at `x`. It equals `scipy.interpolate.CubicSpline` with `bc_type='natural'`. Outside the domain the cubic of the first or the last interval is continued (extrapolation, like scipy; the second derivative is not zero there, so the extrapolation is cubic, not linear). With 2 points the spline is the straight line. Throws `ex-info` (with `:type :invalid-input`, `:method :cubic` and a `:property`) when the lengths differ, there are fewer than 2 points, `xs` contains `NaN` or an infinity, or `xs` is not strictly increasing (unsorted or duplicated). See also [[fastmath.interpolation.linear/linear]], [[fastmath.interpolation.monotone/monotone]], [[cubic-2d]].
(cubic-2d xs ys vss)Creates a 2D natural cubic spline interpolator on a rectangular grid.
The surface is a tensor product of natural cubic splines: for a query point the splines along ys through every row of vss are evaluated at y, and a natural cubic spline along xs through these values is evaluated at x. Note that the end conditions are natural (zero second derivative), not not-a-knot as in scipy.interpolate.RectBivariateSpline, so the two differ near the border of the grid. The result equals two passes of scipy.interpolate.CubicSpline with bc_type='natural'.
Parameters:
xs (sequence of numbers): nodes along the first axis, finite and strictly increasing; at least 2 points.ys (sequence of numbers): nodes along the second axis, finite and strictly increasing; at least 2 points.vss (sequence of sequences): values, (count xs) rows with (count ys) values each; vss[i][j] is the value at (xs[i], ys[j]).Returns a function f such that (f x y) or (f [x y]) returns the interpolated double value. Outside the grid the end cubics are continued (extrapolation). A spline along xs is built for every query, so evaluation costs O(number of rows) plus the spline set up.
Throws ex-info (with :type :invalid-input, :method :cubic-2d and a :property) when an axis has fewer than 2 points, contains NaN or an infinity, is not strictly increasing, or when the shape of vss does not match the axes (:shape-mismatch).
See also cubic, fastmath.interpolation.linear/bilinear.
Creates a 2D natural cubic spline interpolator on a rectangular grid. The surface is a tensor product of natural cubic splines: for a query point the splines along `ys` through every row of `vss` are evaluated at `y`, and a natural cubic spline along `xs` through these values is evaluated at `x`. Note that the end conditions are natural (zero second derivative), not not-a-knot as in `scipy.interpolate.RectBivariateSpline`, so the two differ near the border of the grid. The result equals two passes of `scipy.interpolate.CubicSpline` with `bc_type='natural'`. Parameters: - `xs` (sequence of numbers): nodes along the first axis, finite and strictly increasing; at least 2 points. - `ys` (sequence of numbers): nodes along the second axis, finite and strictly increasing; at least 2 points. - `vss` (sequence of sequences): values, `(count xs)` rows with `(count ys)` values each; `vss[i][j]` is the value at `(xs[i], ys[j])`. Returns a function `f` such that `(f x y)` or `(f [x y])` returns the interpolated `double` value. Outside the grid the end cubics are continued (extrapolation). A spline along `xs` is built for every query, so evaluation costs O(number of rows) plus the spline set up. Throws `ex-info` (with `:type :invalid-input`, `:method :cubic-2d` and a `:property`) when an axis has fewer than 2 points, contains `NaN` or an infinity, is not strictly increasing, or when the shape of `vss` does not match the axes (`:shape-mismatch`). See also [[cubic]], [[fastmath.interpolation.linear/bilinear]].
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 |