(step xs ys)(step xs ys {:keys [point] :or {point 0.5}})Creates a piecewise constant interpolator with the step inside each interval.
Within each interval between two neighbouring nodes xs[i] and xs[i+1] the function switches from ys[i] to ys[i+1] at the position xs[i] + point * (xs[i+1] - xs[i]). With the default :point 0.5 the value at x is the y of the nearest node and a tie (exactly the middle of the interval) goes to the right node, which equals scipy.interpolate.interp1d with kind='nearest-up'. The function takes the node value exactly at each node.
Parameters:
xs (sequence of numbers): nodes, finite and strictly increasing; at least 2 points.ys (sequence of numbers): values, the same length as xs.opts (map, optional):
:point (double, default: 0.5): position of the step inside an interval as a fraction of its width. 0.0 gives the same function as step-before and 1.0 the same as step-after.Returns a function f such that (f x) returns the double value at x. Left of the first node f returns the first value, right of the last node it returns the last value.
Throws ex-info (with :type :invalid-input, :method :step and a :property) when the lengths differ, there are fewer than 2 points, xs contains NaN or an infinity, or is not strictly increasing.
See also step-before, step-after.
Creates a piecewise constant interpolator with the step inside each interval.
Within each interval between two neighbouring nodes `xs[i]` and `xs[i+1]` the function switches from `ys[i]` to `ys[i+1]` at the position `xs[i] + point * (xs[i+1] - xs[i])`. With the default `:point` 0.5 the value at `x` is the `y` of the nearest node and a tie (exactly the middle of the interval) goes to the right node, which equals `scipy.interpolate.interp1d` with `kind='nearest-up'`. The function takes the node value exactly at each node.
Parameters:
- `xs` (sequence of numbers): nodes, finite and strictly increasing; at least 2 points.
- `ys` (sequence of numbers): values, the same length as `xs`.
- `opts` (map, optional):
- `:point` (double, default: 0.5): position of the step inside an interval as a fraction of its width. `0.0` gives the same function as [[step-before]] and `1.0` the same as [[step-after]].
Returns a function `f` such that `(f x)` returns the `double` value at `x`. Left of the first node `f` returns the first value, right of the last node it returns the last value.
Throws `ex-info` (with `:type :invalid-input`, `:method :step` and a `:property`) when the lengths differ, there are fewer than 2 points, `xs` contains `NaN` or an infinity, or is not strictly increasing.
See also [[step-before]], [[step-after]].(step-after xs ys)Creates a right-continuous piecewise constant (step) interpolator, the step occurs after each node.
The value at x is the y of the nearest node on the left, that is the largest xs[i] that is less than or equal to x. Hence the function is continuous from the right: it jumps at each node and takes the value of that node there. It equals scipy.interpolate.interp1d with kind='previous' (and steps-post of matplotlib).
Parameters:
xs (sequence of numbers): nodes, finite and strictly increasing; at least 1 point.ys (sequence of numbers): values, the same length as xs.Returns a function f such that (f x) returns the double value at x. Left of the first node f returns the first value, right of the last node it returns the last value.
Throws ex-info (with :type :invalid-input, :method :step-after and a :property) when the lengths differ, xs is empty, contains NaN or an infinity, or is not strictly increasing.
See also step-before, step.
Creates a right-continuous piecewise constant (step) interpolator, the step occurs after each node. The value at `x` is the `y` of the nearest node on the left, that is the largest `xs[i]` that is less than or equal to `x`. Hence the function is continuous from the right: it jumps at each node and takes the value of that node there. It equals `scipy.interpolate.interp1d` with `kind='previous'` (and `steps-post` of matplotlib). Parameters: - `xs` (sequence of numbers): nodes, finite and strictly increasing; at least 1 point. - `ys` (sequence of numbers): values, the same length as `xs`. Returns a function `f` such that `(f x)` returns the `double` value at `x`. Left of the first node `f` returns the first value, right of the last node it returns the last value. Throws `ex-info` (with `:type :invalid-input`, `:method :step-after` and a `:property`) when the lengths differ, `xs` is empty, contains `NaN` or an infinity, or is not strictly increasing. See also [[step-before]], [[step]].
(step-before xs ys)Creates a left-continuous piecewise constant (step) interpolator, the step occurs before each node.
The value at x is the y of the nearest node on the right, that is the smallest xs[i] that is greater than or equal to x. Hence the function is continuous from the left: it jumps just after each node and takes the value of that node there. It equals scipy.interpolate.interp1d with kind='next' (and steps-pre of matplotlib).
Parameters:
xs (sequence of numbers): nodes, finite and strictly increasing; at least 1 point.ys (sequence of numbers): values, the same length as xs.Returns a function f such that (f x) returns the double value at x. Left of the first node f returns the first value, right of the last node it returns the last value.
Throws ex-info (with :type :invalid-input, :method :step-before and a :property) when the lengths differ, xs is empty, contains NaN or an infinity, or is not strictly increasing.
See also step-after, step.
Creates a left-continuous piecewise constant (step) interpolator, the step occurs before each node. The value at `x` is the `y` of the nearest node on the right, that is the smallest `xs[i]` that is greater than or equal to `x`. Hence the function is continuous from the left: it jumps just after each node and takes the value of that node there. It equals `scipy.interpolate.interp1d` with `kind='next'` (and `steps-pre` of matplotlib). Parameters: - `xs` (sequence of numbers): nodes, finite and strictly increasing; at least 1 point. - `ys` (sequence of numbers): values, the same length as `xs`. Returns a function `f` such that `(f x)` returns the `double` value at `x`. Left of the first node `f` returns the first value, right of the last node it returns the last value. Throws `ex-info` (with `:type :invalid-input`, `:method :step-before` and a `:property`) when the lengths differ, `xs` is empty, contains `NaN` or an infinity, or is not strictly increasing. See also [[step-after]], [[step]].
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 |