Questions tagged [euclidean-distance]

the Euclidean distance or Euclidean metric is the "ordinary" distance between two points that one would measure with a ruler, and is given by the Pythagorean formula.

In mathematics, the Euclidean distance or Euclidean metric is the "ordinary" distance between two points that one would measure with a ruler, and is given by the Pythagorean formula. By using this formula as distance, Euclidean space (or even any inner product space) becomes a metric space. The associated norm is called the Euclidean norm.

http://en.wikipedia.org/wiki/Euclidean_distance

941 questions
4
votes
3 answers

How to calculate euclidean distance between pair of rows of a numpy array

I have a numpy array like: import numpy as np a = np.array([[1,0,1,0], [1,1,0,0], [1,0,1,0], [0,0,1,1]]) I would like to calculate euclidian distance between each pair of rows. from scipy.spatial import…
Rashmi Singh
  • 519
  • 1
  • 8
  • 20
4
votes
1 answer

Similarity Measurement between Color Image (OpenCV)

I'm working with a CBIR (Content-based Image Retrieval) project which will draw RGB histogram of images and also calculate the distance between other images with query image. I'm using VS 2008 - MFC and OpenCV Library. The method I wanted to use for…
4
votes
2 answers

Euclidean Minimal Spanning Tree and Delaunay Triangulation

I want to calculate the minimal spanning tree based on the euclidean distance between a set of points on a 2D-plane. My current code stores all the edges, and then performs Prim's algorithm in order to get the minimal spanning tree. However, I am…
4
votes
1 answer

Calculating Euclidean Distance With Given Lists

def distance(alist, blist): sum_of = 0 for x in alist: for y in blist: ans = (x - y)**2 sum_of += ans return (sum_of)**(1/2) print(distance([1, 1, 3], [2, 2, 3])) #1.4142135623730951 print(distance([1, 2,…
Laser
  • 43
  • 1
  • 4
4
votes
1 answer

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 want to place weight on each attribute by order of…
user1010101
  • 2,062
  • 7
  • 47
  • 76
4
votes
1 answer

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 shortest path algorithm, such as A* then that…
4
votes
2 answers

Calculate the euclidean distance in scipy csr matrix

I need to calculate the Euclidean Distance between all points that is stored in csr sparse matrix and some lists of points. It would be easier for me to convert the csr to a dense one, but I couldn't due to the lack of memory, so I need to keep it…
Rochana Nana
  • 85
  • 1
  • 5
4
votes
2 answers

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 test images against the training set of 10k images…
wodzu
  • 3,004
  • 3
  • 25
  • 41
4
votes
1 answer

How to find the closest corresponding vectors between two coordinate matrices?

I have the following problem in Python I need to solve: Given two coordinate matrices (NumPy ndarrays) A and B, find for all coordinate vectors a in A the corresponding coordinate vectors b in B, such that the Euclidean distance ||a-b|| is…
jjepsuomi
  • 4,223
  • 8
  • 46
  • 74
4
votes
2 answers

Pass coordinates of 2D Numpy pixel array to distance function

I'm working on an image processing program with OpenCV and numpy. For most pixel operations, I'm able to avoid nested for loops by using np.vectorize(), but one of the functions I need to implement requires as a parameter the 'distance from center',…
xShirase
  • 11,975
  • 4
  • 53
  • 85
4
votes
3 answers

Compute numpy array pairwise Euclidean distance except with self

edit: this question is not specifically about calculating distances, rather the most efficient way to loop through a numpy array, specifying that for index i all comparisons should be made with the rest of the array, as long as the second index is…
phloem7
  • 220
  • 2
  • 12
4
votes
4 answers

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 List2 is closest (euclidean distance) to a point in…
user59634
4
votes
3 answers

In Numpy, find Euclidean distance between each pair from two arrays

I have two arrays of 2D coordinate points (x,y) a = [ (x1,y1), (x2,y2), ... (xN,yN) ] b = [ (X1,Y1), (X2,Y2), ... (XN,YN) ] How can I find the Euclidean distances between each aligned pairs (xi,yi) to (Xi,Yi) in an 1xN array? The…
LWZ
  • 11,670
  • 22
  • 61
  • 79
4
votes
2 answers

Error - Calculating Euclidean distance for PCA in python

I am trying to implement face recognition by Principal Component Analysis (PCA) using python. I am following the steps in this tutorial:…
user2229953
  • 1,569
  • 3
  • 16
  • 24
4
votes
1 answer

NaN distances in Mahout Euclidean implementation

We're using the EuclideanDistanceSimilarity class to calculate the similarity of a bunch of items using Hadoop. Unfortunately some items are getting zero or very few resulting similar items despite being highly similar to items. I think I've…
Tom Martin
  • 2,498
  • 3
  • 29
  • 37