Nearest Scatter Surface Class
Definition
Assembly: Numerics.NET (in Numerics.NET.dll) Version: 10.1.0
public sealed class NearestScatterSurface : SurfaceRemarks
The NearestScatterSurface class implements the simplest form of scattered data interpolation: for any query point x, it returns the function value fᵢ associated with the nearest sample point pᵢ.
Interpolation method: Given N sample points pᵢ ∈ ℝᴰ with values fᵢ, the interpolant is defined as:
s(x) = f_nearest, where nearest = argminᵢ ||x - pᵢ||
This produces a piecewise constant function with Voronoi-like regions around each data point. The interpolant is discontinuous at the boundaries between regions.
Properties:
- Works in any number of dimensions.
- Defined everywhere in ℝⁿ (no extrapolation concerns).
- Produces discontinuous, piecewise constant output.
- Gradient is zero almost everywhere (except at measure-zero boundaries).
Performance: The current implementation uses brute-force linear search with O(N) evaluation cost per query, where N is the number of sample points. In case of ties (multiple points at the same minimum distance), the point with the smallest index is selected.
Note: Future versions may implement spatial indexing (e.g., k-d tree) to improve query performance to O(log N).
Use cases: Nearest-neighbor interpolation is useful for:
- Categorical or discrete data where smooth interpolation is inappropriate.
- Fast lookups when continuity is not required.
- Initial prototyping or as a fallback method.
- Debugging or visualization of sample point coverage.
The NearestScatterSurface class inherits from Surface and works in arbitrary dimensions. Create instances using the ScatteredNearestInterpolator(Matrix<Double>, Vector<Double>) factory methods.
Properties
Methods
| Equals | Determines whether the specified object is equal to the current object. (Inherited from Object) |
| Evaluate(Double[]) |
Evaluates the surface at the specified point.
(Inherited from Surface) |
| Evaluate( |
Evaluates the surface at the specified point.
(Inherited from Surface) |
| Evaluate( |
Evaluates the surface at the specified point.
(Overrides Surface.Evaluate(ReadOnlySpan<Double>)) |
| Evaluate( |
Evaluates the surface at multiple points specified by a list of vectors.
(Inherited from Surface) |
| Evaluate( |
Evaluates the surface at multiple points specified by a read-only span of vectors.
(Inherited from Surface) |
| Evaluate( |
Evaluates the surface at multiple points stored in column-major layout.
(Inherited from Surface) |
| Get | Serves as the default hash function. (Inherited from Object) |
| Get | Gets the Type of the current instance. (Inherited from Object) |
| Gradient( |
Computes the gradient of the surface at the specified point.
(Inherited from Surface) |
| Gradient( |
Computes the gradient of a 2D surface at the specified point.
(Inherited from Surface) |
| Gradient( |
Computes the gradient of the surface at the specified point.
(Overrides Surface.Gradient(ReadOnlySpan<Double>, Span<Double>)) |
| Gradient( |
Computes the gradient of the surface at the specified point.
(Inherited from Surface) |
| Gradients( |
Computes the gradients of the surface at multiple points.
(Inherited from Surface) |
| Gradients( |
Computes the gradients of the surface at multiple points.
(Inherited from Surface) |
| Hessian |
Computes the Hessian matrix of the surface at the specified point.
(Inherited from Surface) |
| ToString | Returns a string that represents the current object. (Inherited from Object) |