Microsphere projection interpolation of scattered data (Apache Commons Math).
Microsphere projection interpolation of scattered data (Apache Commons Math).
(microsphere-projection xss ys)(microsphere-projection xss ys opts)Creates the microsphere projection interpolator of scattered data in any dimension.
The method (the algorithm of Dudziak as implemented in Apache Commons Math) places a microsphere with facets in the query point and lights every facet by the nodes, with the brightness falling with the distance. The value is the sum of the illumination of the facets, weighted by the values at the nodes. It passes through the nodes (within :no-interpolation-tolerance), returns :background where the sphere is dark, and is usually less accurate than fastmath.interpolation.rbf/rbf on smooth data.
Parameters:
xss (sequence): the nodes, at least one; numbers or sequences of one number for one dimensional data, sequences of numbers of an equal dimension otherwiseys (sequence of numbers): the values at the nodes, as many as nodesopts (map, optional; a nil value is the same as a missing key):
:elements (long, default: max(5, 4 + dimension, n / 5) with n the number of nodes): the number of facets of the microsphere; more facets give a smoother and more accurate result and a longer evaluation (the cost is proportional to the number of facets and nodes):exponent (double, default: 1.0): the exponent of the brightness 1 / distance^exponent, not negative; the original paper uses 2, a larger value makes the result closer to the value of the nearest node:max-dark-friction (double, default: 0.9): the largest fraction of the facets which can be dark (not lit by any node) for the value to be computed; above it the :background is returned:dark-threshold (double, default: 0.01): the illumination below which a facet counts as dark:background (double, default: 0.0): the value returned where the sphere is too dark:no-interpolation-tolerance (double, default: 1.0e-6): the distance to a node below which the value of the node is returned:rng (random number generator, default: a new unseeded generator for every call): the generator of the random facets for the dimensions other than 2, see fastmath.random/rng. Pass a seeded one to get the same interpolator on every construction (the generator is consumed); equal seeds give equal values and different seeds give different values. In two dimensions the facets are equally spaced angles (deterministic) and :rng is not usedReturns a function of a query point (a number or a one element sequence for one dimensional data, a sequence of numbers otherwise; in two dimensions also two numbers (f x y)) returning a double. The function is safe to call from several threads (calls are serialised).
The result depends on the facets: in dimensions other than 2 the sphere is random, so without a seeded :rng two constructions differ (by up to about 0.2 on a smooth test function), and the default number of facets is a compromise (a few hundred facets are more accurate).
Throws ex-info (with :type :invalid-input, :method :microsphere-projection and the key :property) when xss and ys have different lengths (:length-mismatch), there are no nodes (:too-few-points), the nodes have different dimensions (:dimension-mismatch, also for a query of a wrong dimension), or :elements is below 1 or :exponent is negative or not finite.
See also fastmath.interpolation/microsphere-projection, fastmath.interpolation.rbf/rbf, fastmath.interpolation.shepard/shepard.
Creates the microsphere projection interpolator of scattered data in any dimension.
The method (the algorithm of Dudziak as implemented in Apache Commons Math) places a microsphere with facets in the query point and lights every facet by the nodes, with the brightness falling with the distance. The value is the sum of the illumination of the facets, weighted by the values at the nodes. It passes through the nodes (within `:no-interpolation-tolerance`), returns `:background` where the sphere is dark, and is usually less accurate than [[fastmath.interpolation.rbf/rbf]] on smooth data.
Parameters:
- `xss` (sequence): the nodes, at least one; numbers or sequences of one number for one dimensional data, sequences of numbers of an equal dimension otherwise
- `ys` (sequence of numbers): the values at the nodes, as many as nodes
- `opts` (map, optional; a `nil` value is the same as a missing key):
- `:elements` (long, default: `max(5, 4 + dimension, n / 5)` with `n` the number of nodes): the number of facets of the microsphere; more facets give a smoother and more accurate result and a longer evaluation (the cost is proportional to the number of facets and nodes)
- `:exponent` (double, default: `1.0`): the exponent of the brightness `1 / distance^exponent`, not negative; the original paper uses `2`, a larger value makes the result closer to the value of the nearest node
- `:max-dark-friction` (double, default: `0.9`): the largest fraction of the facets which can be dark (not lit by any node) for the value to be computed; above it the `:background` is returned
- `:dark-threshold` (double, default: `0.01`): the illumination below which a facet counts as dark
- `:background` (double, default: `0.0`): the value returned where the sphere is too dark
- `:no-interpolation-tolerance` (double, default: `1.0e-6`): the distance to a node below which the value of the node is returned
- `:rng` (random number generator, default: a new unseeded generator for every call): the generator of the random facets for the dimensions other than 2, see [[fastmath.random/rng]]. Pass a seeded one to get the same interpolator on every construction (the generator is consumed); equal seeds give equal values and different seeds give different values. In two dimensions the facets are equally spaced angles (deterministic) and `:rng` is not used
Returns a function of a query point (a number or a one element sequence for one dimensional data, a sequence of numbers otherwise; in two dimensions also two numbers `(f x y)`) returning a double. The function is safe to call from several threads (calls are serialised).
The result depends on the facets: in dimensions other than 2 the sphere is random, so without a seeded `:rng` two constructions differ (by up to about 0.2 on a smooth test function), and the default number of facets is a compromise (a few hundred facets are more accurate).
Throws `ex-info` (with `:type :invalid-input`, `:method :microsphere-projection` and the key `:property`) when `xss` and `ys` have different lengths (`:length-mismatch`), there are no nodes (`:too-few-points`), the nodes have different dimensions (`:dimension-mismatch`, also for a query of a wrong dimension), or `:elements` is below 1 or `:exponent` is negative or not finite.
See also [[fastmath.interpolation/microsphere-projection]], [[fastmath.interpolation.rbf/rbf]], [[fastmath.interpolation.shepard/shepard]].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 |