(barycentric xs ys)(barycentric xs ys {:keys [order]})Creates a 1D barycentric rational interpolator (Floater-Hormann).
The interpolant is the barycentric rational function with the Floater-Hormann weights of the given order: a blend of local polynomial interpolants of degree order through order + 1 neighbouring nodes. It has no poles on the real line for any distribution of nodes and passes through all data points. The approximation order is order + 1 for smooth data, so a higher order gives a better fit for smooth data, up to the polynomial interpolant for order equal to (count xs) - 1, which is the least robust choice. Order 0 gives the Berrut rational interpolant with alternating weights. For order close to the number of points on equispaced nodes the usual instability of high degree polynomial interpolation returns.
Parameters:
xs (sequence of numbers): nodes, finite and distinct; they do not need to be sorted (the nodes are sorted internally, the weights are defined by the neighbourhood in the sorted order).ys (sequence of numbers): values, the same length as xs.opts (map, optional):
:order (integer, default: 1): blending degree, an integer-valued number with 0 <= order <= (count xs) - 1. A double with an integer value is accepted.Returns a function f such that (f x) returns the interpolated double value at x. A query exactly equal to a node returns the value of that node. Outside the domain the rational function is evaluated as is (extrapolation, accuracy decreases quickly).
Throws ex-info (with :type :invalid-input, :method :barycentric and a :property) when the lengths differ, there are no points (:too-few-points), xs contains NaN or an infinity (:not-finite), xs has duplicates (:duplicate-nodes), or :order is not an integer-valued number in the range above (:invalid-order, that includes an order for which there are too few points).
See also polynomial, fastmath.interpolation.cubic/cubic.
Creates a 1D barycentric rational interpolator (Floater-Hormann).
The interpolant is the barycentric rational function with the Floater-Hormann weights of the given order: a blend of local polynomial interpolants of degree `order` through `order + 1` neighbouring nodes. It has no poles on the real line for any distribution of nodes and passes through all data points. The approximation order is `order + 1` for smooth data, so a higher `order` gives a better fit for smooth data, up to the polynomial interpolant for `order` equal to `(count xs) - 1`, which is the least robust choice. Order 0 gives the Berrut rational interpolant with alternating weights. For order close to the number of points on equispaced nodes the usual instability of high degree polynomial interpolation returns.
Parameters:
- `xs` (sequence of numbers): nodes, finite and distinct; they do not need to be sorted (the nodes are sorted internally, the weights are defined by the neighbourhood in the sorted order).
- `ys` (sequence of numbers): values, the same length as `xs`.
- `opts` (map, optional):
- `:order` (integer, default: 1): blending degree, an integer-valued number with `0 <= order <= (count xs) - 1`. A `double` with an integer value is accepted.
Returns a function `f` such that `(f x)` returns the interpolated `double` value at `x`. A query exactly equal to a node returns the value of that node. Outside the domain the rational function is evaluated as is (extrapolation, accuracy decreases quickly).
Throws `ex-info` (with `:type :invalid-input`, `:method :barycentric` and a `:property`) when the lengths differ, there are no points (`:too-few-points`), `xs` contains `NaN` or an infinity (`:not-finite`), `xs` has duplicates (`:duplicate-nodes`), or `:order` is not an integer-valued number in the range above (`:invalid-order`, that includes an order for which there are too few points).
See also [[polynomial]], [[fastmath.interpolation.cubic/cubic]].(polynomial xs ys)Creates a 1D polynomial interpolator in the barycentric form.
The interpolant is the unique polynomial of degree (count xs) - 1 through all data points. It is the barycentric interpolant with :order equal to (count xs) - 1, evaluated with the barycentric formula, which is numerically stable for well distributed nodes (for example Chebyshev nodes). On equispaced nodes with many points the polynomial interpolation itself is ill-conditioned (Runge's phenomenon), whatever the algorithm.
Parameters:
xs (sequence of numbers): nodes, finite and distinct; at least 2 points; they do not need to be sorted.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. A query exactly equal to a node returns the value of that node. Outside the domain the polynomial is evaluated as is (extrapolation).
Throws ex-info (with :type :invalid-input, :method :polynomial and a :property) when the lengths differ, there are fewer than 2 points, xs contains NaN or an infinity, or xs has duplicates (:duplicate-nodes).
See also barycentric.
Creates a 1D polynomial interpolator in the barycentric form. The interpolant is the unique polynomial of degree `(count xs) - 1` through all data points. It is the [[barycentric]] interpolant with `:order` equal to `(count xs) - 1`, evaluated with the barycentric formula, which is numerically stable for well distributed nodes (for example Chebyshev nodes). On equispaced nodes with many points the polynomial interpolation itself is ill-conditioned (Runge's phenomenon), whatever the algorithm. Parameters: - `xs` (sequence of numbers): nodes, finite and distinct; at least 2 points; they do not need to be sorted. - `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`. A query exactly equal to a node returns the value of that node. Outside the domain the polynomial is evaluated as is (extrapolation). Throws `ex-info` (with `:type :invalid-input`, `:method :polynomial` and a `:property`) when the lengths differ, there are fewer than 2 points, `xs` contains `NaN` or an infinity, or `xs` has duplicates (`:duplicate-nodes`). See also [[barycentric]].
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 |