test_nearest, a MATLAB code which tests several functions that carry out the nearest neighbor calculation.
In a nearest neighbor calculation, we are given:
Obviously, one method to determine the values in NEAREST is simply to compute every distance and take the index of the minimum. But even this simple idea can be implemented in many ways in MATLAB, and implementations will vary in their cost in memory and time.
Also, note that if the dimension M is small, and if the size of the R set is small relative to that of S, it may be much cheaper to compute the Delaunay triangulation of R (or its higher-dimensional generalization). Computing the triangulation is somewhat expensive, but makes the search procedure extremely quick.
Lloyd's version of the Centroidal Voronoi Tessellation (CVT) algorithm estimates the area or volume of the cells using sampling. This computation is a nearest neighbor calculation.
The computer code and data files described and made available on this web page are distributed under the GNU LGPL license.
test_nearest is available in a C version and a C++ version and a FORTRAN90 version and a MATLAB version.
cvt, a MATLAB code which computes elements of a centroidal voronoi tessellation (cvt).
nearest_interp_1d, a MATLAB code which interpolates a set of data using a piecewise constant interpolant defined by the nearest neighbor criterion.
nearest_neighbor, a MATLAB code which works in a given m-dimensional space, seeking, for each point in a set s, the nearest point in a set r, by richard brown.