Questions tagged [nearest]

Questions on the usage of Nearest and creating a custom distance function for it; also on NearestNeighborGraph, RegionNearest, GeoNearest and related concepts.

Filter by
Sorted by
Tagged with
1
vote
0answers
31 views

Nearest Region of a Point-cloud

For a given examplary set of points p(2D) with known NearestFunction nf ...
9
votes
2answers
346 views

Drawing lines between nearest neighbor points

I am reading a file with 4 columns (índex and 3 coordinates) and I want to plot spheres at these positions: ...
6
votes
1answer
50 views

NearestTo causes a kernel crash when applied to a list of SparseArrays [closed]

Nearest and NearestTo cause a kernel crash on Mathematica 12.0.0 for Mac OS X. (running on OS X 10.11.6) when operating on a list of SparseArray vectors. Here's my minimal breaking example: ...
2
votes
2answers
62 views

How to Create an Efficient Step Function from Data

I have list of rules from where a DateListStepPlot can be created to visualize the problem: ...
3
votes
2answers
231 views

Find the smallest and largest distance between two points distributed in 3D space

Suppose I have some 3D points, e.g. {{0, 0, 1}, {0, 0, 1.3}, {0, 1, 0}, {1.2, 0, 0}}. Now I want to find the smallest and largest distance between two points. A ...
10
votes
2answers
217 views

Efficient multicolor search

I'm hoping someone can help me improve the following fun code-snippet, which takes a target color and searches through a set of images to find the ones that most closely match: ...
0
votes
0answers
25 views
8
votes
2answers
205 views

Speeding up Nearest with multiple distance thresholds

Consider the following example of using Nearest: ...
14
votes
3answers
381 views

Is there a built-in function I can use to measure the similarity of two trees?

This is a higher level question, and I don't expect a full answer, but maybe a nudge in the right direction would help, or maybe there is a built in Mathematica function that does something very ...
4
votes
2answers
229 views

How to use Nearest as a lookup function?

I have data1 and a target point targetPts, and want to find the closest point from the data. As you can see from below, the 29th ...
8
votes
3answers
149 views

How to connect all points in a graph generated by a set of given vertexes?

I am trying to construct a tree by looking at the nearest neighbors (or just approximately nearest for higher efficient) of a set of given vertexes. I first try this:- ...
1
vote
0answers
73 views

Estimating Lyapunov exponent from a time series problem [duplicate]

I am trying to use this code for estimating L.e.: ...
6
votes
2answers
229 views

Find the element in a list of triples which has z-coordinate nearest a specified value

Here is my list coordinate {x,y,z} ...
1
vote
2answers
598 views

Finding the x-value corresponding to a y-value found using Nearest [closed]

I have a large 2d array of infinite precision named "data" of x values and y values. I am using Nearest to find the y-value closest to a specified number, say 0....
3
votes
0answers
112 views

Getting Distances from Nearest Function [closed]

I am fairly new to mathematica. I am trying to find a way to mock python's KDTree.query function in mathematica. Basically I have 9 vectors (each length two). I want to know the three closest vectors ...
4
votes
4answers
212 views

Forming tracks of coordinates depending on distance

I have a list that consists of certain number of coordinates sub-lists (here 8). (The following data are only an example to describe my problem.) ...
1
vote
1answer
108 views

Define a 3D surface for input in Region function

I am looking for the shortest distance from a 3D surface to a random point, and also for the exact point on the surface. These are the definitions and visualization. ...
5
votes
1answer
301 views

Nearest non-collinear/non-coplanar points

This is a long post. Most of it is just an introduction so the question itself is understandable. The question is in bold. Just skip to it if you want to hear the point. Everything below the question ...
2
votes
1answer
81 views

How can I get get index and distance in Nearest functions in Low Version [closed]

Nearest[{"I'm", "sorry", "Dave"} -> All, "David"] {<|"Element" -> "Dave", "Index" -> 3, "Distance" -> 2|>} However, in a WolframScript.wl file, ...
3
votes
1answer
375 views

Opposite of Nearest?

There is an useful function Nearest in Mathematica, which finds the element in the aggregate given as its 1st argument that is nearest to its 2nd argument. It is ...
1
vote
0answers
106 views

A question for Nearest [closed]

Assume that I want to get nearest 10 points of a thousand random points in a given area to original point in three-dimensional coordinate system. Does anyone know how the ...
1
vote
2answers
176 views

Using Nearest with periodic boundary conditions of a list

Take the list e = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10} I want to get the nearest points but with a wraparound condition. So lets say I want to find the 5 nearest ...
4
votes
1answer
266 views

How to rapidly find the nearest pairs of points in different clusters

Background For speed up this question or this question,I have such need. Current try: Suppose I have $3$ clusters of points: ...
5
votes
1answer
156 views

How to find the index of a facet of a boundary mesh region closest to a given point?

Using the RegionNearest[] function, it is possible to calculate the point, $p_{mesh}$, on a mesh region that is nearest to some input point, $p_{input}$. My ...
3
votes
1answer
681 views

Better way to use Nearest

I'm trying to write a snippet of code that, given an input value (value), checks a list of arbitrary length (data) for the ...
1
vote
2answers
155 views

Finding Nearest Element to a line in a 2 dimensional Array

I have a 2-dimensional list of data of $x$ and $y$ coordinates. I am looking for a way to get the element of the list which has the closest $y$ value to a given $y$ value. I tried using ...
3
votes
3answers
224 views

Question about Nearest [duplicate]

In the following example Nearest finds the nearest values between list1 and list2 and ...
4
votes
3answers
686 views

Remove 2D points where nearest neighbor exceeds certain distance

I have the following 2D points: ...
5
votes
3answers
426 views

Mean distance beween nearest 2 coordinates

I have as an example the following 2d-coordinates: ...
4
votes
2answers
326 views

Tracing 2d coordinates by using Nearest function

In 5 digital images I have determined the 2d coordinates of detected objects. The resulting coordinate list can be downloaded from here: http://pastebin.com/7bE0CEJ5 ...
1
vote
3answers
212 views

Why won't DiscretizeRegion work with a custom distance function?

I am trying (in 10.0) to create a region from a list of data points. I have created myDistance to use as the boolean test for whether or not a point should be included in the region ...
4
votes
1answer
222 views

Draw lines between all neighbours

I have seen this question, but what I want is a bit different. I have a set of data (blue points) and I would like to end up with something like this: , i.e. joining each site with all its (nearest)...
1
vote
1answer
243 views

precision and speed inefficiency issues of Nearest function with sqrt expression [closed]

Recently, Nearest has been attacked for many bugs. Some are already fixed. I am going to show some issues when Nearest applied ...
4
votes
2answers
658 views

How to get Nearest lower value?

Nearestgives me the closest value to my reference, but what if I am always looking for the closest value, which is lower than my reference? ...
10
votes
1answer
226 views

Why does Nearest not support Sqrt?

Bug introduced in 10.0.2 and fixed in 10.3.0 Simple examples with two points nf1=Nearest[{{0, 0}, {Sqrt[2], Sqrt[2]}}] nf1[{0, 0}, {All, 2.1}] gives ...
15
votes
3answers
752 views

Cannot get nearest neighbors from Nearest

Bug introduced in 10 and fixed in 10.3 There still persists the failure to return 30.72 (another bug according to Daniel Lichtblau but from the developer's point of view it may be a feature). ...
10
votes
3answers
390 views

Using an ellipse as a threshold for Nearest function

The Nearest function can receive as a threshold parameter a radius to look for elements inside that. From the documentation: ...
4
votes
3answers
805 views

Find nearest distance of an interior point from perimeter

By definition, the interior point is a point inside an arbitrary region like this: In picture above, $y$ is an interior point of region. My question is how to find the distance of an interior point ...
7
votes
4answers
2k views

efficient way to give nearest neighbour and next nearest neighbour of every point in a point set

Suppose we have a point set, the points are labeled 1,2,3,....n. And p[i] is the coordinate of the point. Now I want the label of nearest and next nearest point (...
3
votes
1answer
431 views

Filtering a point cloud: How to reject some points in a 3D cloud of particles?

I'm having an issue with a 3D distribution of points. The distribution is really nice looking in Mathematica, but it is used in an OpenGL astronomy program (Celestia) to generate a nebula, with ...
9
votes
3answers
475 views

Manually specifying distance metric to Nearest slows down calculation

Why does manually specifying the distance metric to Nearest slow down the calculation so much? This is relevant to my previous question. I've been using ...