All Questions
Tagged with euclidean-distance algorithm
50
questions
15
votes
3
answers
2k
views
Efficient calculation of euclidean distance
I have a MxN array, where M is the number of observations and N is the dimensionality of each vector. From this array of vectors, I need to calculate the mean and minimum euclidean distance between ...
11
votes
5
answers
6k
views
What is the most efficient way to find the euclidean distance in 3d using mysql?
I have a MySQL table with thousands of data points stored in 3 columns R, G, B. how can I find which data point is closest to a given point (a,b,c) using Euclidean distance?
I'm saving RGB values of ...
9
votes
7
answers
10k
views
Identifying points with the smallest Euclidean distance
I have a collection of n dimensional points and I want to find which 2 are the closest. The best I could come up for 2 dimensions is:
from numpy import *
myArr = array( [[1, 2],
[3, 4]...
9
votes
1
answer
3k
views
How to find the farthest point (from a set of points) from a given point efficiently?
I'm looking for an algorithm or data structure to solve the following problem:
You are given a set of points S.
And you are given Q queries in form of another point.
For every query, find the farthest ...
8
votes
3
answers
23k
views
Python alternative for calculating pairwise distance between two sets of 2d points [duplicate]
In Matlab there exists the pdist2 command. Given the matrix mx2 and the matrix nx2, each row of matrices represents a 2d point. Now I want to create a mxn matrix such that (i,j) element represents the ...
5
votes
7
answers
419
views
Find a shortest distance between two buckets of numbers
I have two buckets (unordered, 1-dimentional data structures) of numbers and I want to calculate a minimal distance between any elements of the two buckets. Is there a way to find the shortest ...
5
votes
3
answers
761
views
Find the closest group of vectors, one vector from each set?
I have k sets of vectors. The vectors are all the same length m. The sets are not all the same length, but let's say they have an average length of n vectors in each. I need to find the group of ...
5
votes
2
answers
1k
views
How to efficiently find the two farthest point (Euclidean distance) in an 4-dimensional space given m points?
Given m 4-dimensional points, what is the efficient way to find out the two points that have the maximum Euclidean distance?
Currently, I am just using brute force approach and checking every pair ...
4
votes
4
answers
3k
views
draw a graph where the distance between vertices correspond to the edge weights
Is there an algorithm that gives me coordinates of vertices in a graph, when I give him a weighted graph and the edge weights between vertices points to the distance between vertices?
Something like:
...
4
votes
2
answers
13k
views
Optimize performance for calculation of euclidean distance between two images
I implemented the k-nearest-neighbours algorithm in python to classify some randomly picked images from the mnist database. However I found my distance function to be quite slow: An analisys of 10 ...
4
votes
4
answers
3k
views
Faster way to compare two sets of points in N-dimensional space?
List1 contains a high number (~7^10) of N-dimensional points (N <=10), List2 contains the same or fewer number of N-dimensional points (N <=10).
My task is this: I want to check which point in ...
4
votes
1
answer
2k
views
Continuous space shortest path
I need a shortest path algorithm for controlling a real life robot.
Lets say i have map of the environment in the form of a matrix where 1 is an obstacle and 0 is free space. If i use a conventional ...
4
votes
4
answers
2k
views
What is the best way to check all pixels within certain radius?
I'm currently developing an application that will alert users of incoming rain. To do this I want to check certain area around user location for rainfall (different pixel colours for intensity on ...
4
votes
1
answer
2k
views
Calculating similarity based on attributes
My objective is to calculate the degree of similarity between two users based on their attributes. For instance let's consider a player and consider age, salary, and points as attributes.
Also I ...
3
votes
2
answers
406
views
Path that gets within given distance of each point in order
I have an ordered list of points in a 2D plane. I'd like to find the shortest route such that it gets at least within distance X (or closer) from each point, in the given order. How do I find this ...
3
votes
2
answers
131
views
Generate P random N-dimensional points from list of ALL possible pairwise distances
I would like to generate random N-dimensional points with the constraint of having precise Euclidean distances (known) between each other.
Number of points P = 100
Number of dimensions of the ...
3
votes
1
answer
196
views
Optimise Euclidean distance matrix algorithm if only interested in closest points
The following Euclidean distance algorithm creates a MxM matrix of distances between the rows of an MxN input matrix (representative of points in some N dimensional space). The speed of this algorithm ...
3
votes
1
answer
1k
views
How to calculate the euclidean distance in Python without fixed-dimension?
I intend to calculate the euclidean distance between two sets of big data. I've googled that the module called SciPy will do the work, whose mechanism is via k-d tree.
But I don't have fixed ...
2
votes
7
answers
5k
views
Pairwise Distance Calculation in c++
I'm computing the potential energy of a large (~1e5) number of particles in c++. In order to do this, I'm running a double loop in which I calculate pairwise distances, and from those distance compute ...
2
votes
1
answer
961
views
Min Cost Flow Optimized for a Complete Bipartite Matching in Euclidean Space
The gist is... we have two sets of points A and B. Set A and B have the same number of points n.
Formal Problem:
Construct a minimum cost complete bipartite matching between points in A and B. The ...
2
votes
1
answer
1k
views
Efficient computation of the sum of all pairwise distances of a set of points, all on a finite 2D grid
Given a set of n points in 2D plane. We need to find sum of euclidean distance between every point to every other points i.e. ΣΣdist(P(i)P(j)) for i:[1,n-1], j:[i+1,n]. It is also given that for every ...
2
votes
1
answer
3k
views
Finding euclidean distance between all pair of points
I have 8 points in a list and I need to calculate euclidean distance between all possible pairs. I could write a for loop and go on calculating the distance but is there a better approach / method ...
2
votes
2
answers
4k
views
Hausdorff Distance between Points of two meshes
I have to implement the Hausdorff distance for 2 meshes. The meshes are different segmentation results of an human organ and I have to compare them, one mesh is a gold seg. and the second one the ...
2
votes
0
answers
195
views
Data structure to find farthest point from a point set in logarithmic time
I have a set P of n points in 2-dimensional space. I have to perform the following query on these points:
Given a set X which is a subset of P, find a point in set P\X, which has the maximum distance ...
2
votes
2
answers
152
views
Calculate graph distance based on different edge types
Let's say I have the following unweighted, undirected graph where edges can be connected by two different types of edges: support edges (green) and opposition edges (red).
Here's an example:
I ...
2
votes
0
answers
2k
views
Cannot understand the problem of Bitonic Euclidean Traveling-Salesman [closed]
I am referring to the problem in Introduction to Algorithms. I kind of fail to understand the problem.
From what I see, I need to sort the x-coordinates of the given set of points and then form a ...
1
vote
1
answer
965
views
Given lengths of 3 sides of a triangle, compute an average distance between the middle points of the sides
I have come across a problem. The problem statement is
A team of 3 people, is going to participate in a competition. According to the regulations of this competition, every team is given a single ...
1
vote
3
answers
756
views
Calculate minimal distance between two "pixel blobs" in canvas
I want to calculate the distance between two sets of pixels – for illustration purposes, a blue set and a red set of pixels. I want to calculate the closest distance in x direction, y direction and ...
1
vote
3
answers
919
views
Find euclidean distance of two array of different length
I want to find Euclidean distance to check similarity of strings.
From above image in a painting object field there are many image types in database. Images is displaying using this paining_object ...
1
vote
1
answer
3k
views
grid point algorithm (finding the point in grid)
I am searching for an algorithm such as the closest pair of points algorithm
Instead of an arbitrary distance between all of the points, I have a grid system set up with the 4 points being the top-...
1
vote
2
answers
555
views
Optimal path from a list of points c++
i have this request:
i have a list of points and for each of these i have X, Y coordinate.
my goal is to find the optimal path between these points (I have to use all the points).
for example:
A (xa,...
1
vote
2
answers
1k
views
Travelling Salesman Problem - Best path to go through all points
I am trying to solve an exercise based on the travelling salesman problem. Basically I am provided with a list of points with their coordinates, like this:
[(523, 832), (676, 218), (731, 739), ..] (a ...
1
vote
1
answer
161
views
Is it logical for Manhattan and Euclidean heuristics to check the same nodes?
So I have created an app where I have to find the shortest route from startPos to endPos using the A* algorithm. I have approached this problem with the 2 most common heuristics:
1. Manhattan Distance
...
1
vote
1
answer
722
views
Determining the average euclidean distance between neighbouring points in dataset
I would like to compute the average euclidean distance in a 2D dataset (xCoords , yCoords) but only between neighbouring points.
As an example:
xCoords = [[16.8742 10.7265 30.0538 10.4524 12.6483 15....
1
vote
1
answer
97
views
Apply PHP compare function to all elements in MySQL table
I'm building an algorithm that takes an euclidean coordinate—for example (-4, 2)—and searches through a large database table of other coordinates to find the closest coordinates (using euclidean ...
1
vote
1
answer
38
views
Segment direction in a polar plane
I have the following situation: Base point (green) and segments, for each segment his vertices represented as polar point with theta angle from base point.
The problem: For each segment I have his 2 ...
1
vote
0
answers
161
views
Fastest algorithm to find the max distance within a set of points [duplicate]
Let's say I have a set of points: (i.e. in my case, a list holding all points: pts = [(1,1),(3.4,5),...,(x,y)]). I would like to understand what the fastest approach to finding the maximum distance ...
1
vote
2
answers
1k
views
How do I plot Euclidean distance between tags on X-Y Plane
I have a set of 'N' tags and their Euclidean distances. How do I plot this information on a 2D plane?
For 3 tags, the plot is a triangle where each corner is a tag.
I'm looking for an approximate ...
1
vote
1
answer
484
views
find the most efficient path (in term of shortest distance) between a set of 2D points
I have a set of 2D points stored in a dictionary and i need to find the most efficient path to sampling all points (red traingles) in term of the shortest distance from a start-end point (yellow ...
1
vote
1
answer
2k
views
Find points given distances between them
Here is an example:
Suppose there are 4 points: A, B, C, and D
Given that Point A is at (0,0):
and the distances:
A to B: 7
A to C: 5
A to D: 9
B to C: 6
B to D: 5
C to D: 7
The goal would be to ...
1
vote
5
answers
4k
views
Finding cities close to one another using longitude and latitude [duplicate]
Each user in my db is associated to a city (with it's longitude and latitude)
How would I go about finding out which cities are close to one another?
i.e. in England, Cambridge is fairly close to ...
0
votes
1
answer
91
views
Distance from coastline in R (or fortran) database
`Hi everyone,
I have a really big database (more than 80,000 arrows) with latitud and longitud coordinate which correspond mainly to African Continent, and I was interested in calculate the distance ...
0
votes
5
answers
1k
views
Partition neighbor points given a euclidean distance range
Given two points P,Q and a delta, I defined the equivalence relation ~=, where P ~= Q if EuclideanDistance(P,Q) <= delta. Now, given a set S of n points, in the example S = (A, B, C, D, E, F) and n ...
0
votes
0
answers
113
views
How can I change my algorithm to get the farthest node for each iteration?
So I am trying to pick out the farthest node for each iteration. I start by randomly picking the first node, then continueing by picking the farthest node from the first one.
From there I have two ...
0
votes
1
answer
457
views
Trying to code the nearest neighbours algorithm - euclidean distance function only calculates the distances for one row of the test set - why?
I am trying to code the Nearest Neighbours Algorithm from scratch and have come across a problem - my algorithm was only giving the index/classification of the nearest neighbour for one row/point of ...
0
votes
0
answers
156
views
How to fix Euclidean Distance function? (Movie Recommender)
Something similar to this https://blazingedge.io/blog/movie-recommendation-javascript/
My ecDistance function is getting small similarity scores
For example: .01 - 0059 and smaller. The logic is ...
0
votes
0
answers
45
views
Determination of a given point's closeness to a given set of points [Without using euclidean distance]
I am faced with a problem in which I have to determine weather a random point(Cartesian co-ordinate) is closer in range[euclidean distance] to a set 'N' of points.
I cannot use the following methods ...
0
votes
0
answers
159
views
Online Metric Learning for Face Recognition
I'm using OpenFace to compute representations (in 128D) for faces found in images taken under unconstrained conditions that show significant variations in lighting, time, etc.
According to their ...
-1
votes
2
answers
1k
views
Pairwise distance of points in one dimension
Is it possible to calculate the pairwise distance of a set of points in one dimension (all points are in a line) faster than O(n^2)?
-1
votes
1
answer
6k
views
K-Nearest Neighbor Implementation for Strings (Unstructured data) in Java
I'm looking for implementation for K-Nearest Neighbor algorithm in Java for unstructured data. I found many implementation for numeric data, however how I can implement it and calculate the Euclidean ...