All Questions

Filter by
Sorted by
Tagged with
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 ...
japata's user avatar
  • 329
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 ...
soulkphp's user avatar
  • 3,783
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]...
Ηλίας's user avatar
  • 2,600
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 ...
Nikola Pesic's user avatar
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 ...
user_1_1_1's user avatar
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 ...
oleksii's user avatar
  • 35.7k
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 ...
fariadantes's user avatar
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 ...
user3243499's user avatar
  • 3,061
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: ...
Vladimír Magyar's user avatar
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 ...
wodzu's user avatar
  • 3,112
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 ...
user avatar
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 ...
Kartoffel's user avatar
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 ...
Denis Vitez's user avatar
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 ...
user1010101's user avatar
  • 2,088
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 ...
M. Volf's user avatar
  • 1,393
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 ...
qgius's user avatar
  • 33
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 ...
Atticus's user avatar
  • 176
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 ...
Judking's user avatar
  • 6,211
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 ...
astromax's user avatar
  • 6,071
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 ...
Michael Petrochuk's user avatar
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 ...
Roshan's user avatar
  • 150
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 ...
Sophia's user avatar
  • 387
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 ...
toobee's user avatar
  • 2,682
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 ...
Mateo's user avatar
  • 83
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 ...
user1569339's user avatar
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 ...
Arthur's user avatar
  • 21
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 ...
sanapala mohanarao's user avatar
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 ...
Thomas W's user avatar
  • 15k
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 ...
Komal Goyani's user avatar
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-...
Jake B's user avatar
  • 682
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,...
Safari's user avatar
  • 11.7k
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 ...
Shark44's user avatar
  • 753
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 ...
Chris Costa's user avatar
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....
PhilE's user avatar
  • 131
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 ...
Leopold Joy's user avatar
  • 4,600
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 ...
michael's user avatar
  • 3,905
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 ...
sgerbhctim's user avatar
  • 3,560
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 ...
Satyaki Sanyal's user avatar
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 ...
Gianni Spear's user avatar
  • 7,406
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 ...
Dr C's user avatar
  • 150
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 ...
Flukey's user avatar
  • 6,505
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 ...
Isaac's user avatar
  • 1
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 ...
ceztko's user avatar
  • 14.9k
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 ...
FishyK's user avatar
  • 161
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 ...
uniha2021's user avatar
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 ...
Gracias Peterson Claude's user avatar
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 ...
Arg_Stack's user avatar
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 ...
galoosh33's user avatar
  • 326
-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)?
Mateo's user avatar
  • 83
-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 ...
F. Fo's user avatar
  • 123