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
13
votes
6 answers

Efficient and precise calculation of the euclidean distance

Following some online research (1, 2, numpy, scipy, scikit, math), I have found several ways for calculating the Euclidean Distance in Python: # 1 numpy.linalg.norm(a-b) # 2 distance.euclidean(vector1, vector2) #…
user6167676
13
votes
2 answers

Efficiently compute pairwise squared Euclidean distance in Matlab

Given two sets of d-dimensional points. How can I most efficiently compute the pairwise squared euclidean distance matrix in Matlab? Notation: Set one is given by a (numA,d)-matrix A and set two is given by a (numB,d)-matrix B. The resulting…
matheburg
  • 2,097
  • 1
  • 19
  • 46
12
votes
3 answers

Distance between nodes and the centroid in a kmeans cluster?

Any option to extract the distance between the nodes and the centroid in a kmeans cluster. I have done Kmeans clustering over an text embedding data set and I want to know which are the nodes that are far away from the Centroid in each of the…
Arav
  • 143
  • 1
  • 1
  • 10
12
votes
3 answers

OpenCV euclidean distance between two vectors

I want to calculate the euclidean distance between two vectors (or two Matrx rows, doesn't matter). Is there a good function for that in OpenCV?
farahm
  • 1,326
  • 6
  • 32
  • 70
11
votes
3 answers

How to get cosine distance between two vectors in postgres?

I am wondering if there is a way to get cosine distance of two vectors in postgres. For storing vectors I am using CUBE data type. Below is my table definition: test=# \d vectors …
11
votes
1 answer

Example of increasing the work per thread in CUDA

Algorithm : I'm writing a program with CUDA and the problem is the following: Two matrices A (n * 128) and B (m * 128) I take the first row of A, and I compute the distance between that vector and all the rows of B, one by one. I write the result…
user3734420
11
votes
5 answers

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 colors separately in a table, so the values are…
soulkphp
  • 3,753
  • 2
  • 17
  • 14
10
votes
1 answer

Most Efficient Way to Calculate an SDF to a Triangle Mesh

Hi. I've been gathering info from various sources consistently over the past month, yet without any luck of finding an idea that would suit my particular issue. So here's the formulation of the problem: Given a mesh in a form of buffer geometry…
Martin
  • 141
  • 1
  • 11
10
votes
1 answer

Compute Euclidean distance between rows of two pandas dataframes

I have two pandas dataframes d1 and d2 that look like these: d1 looks like: output value1 value2 value2 1 100 103 87 1 201 97.5 88.9 1 144 54 85 d2 looks like: output …
j1897
  • 1,507
  • 5
  • 21
  • 41
10
votes
2 answers

Find euclidean distance from a point to rows in pandas dataframe

i have a dataframe id lat long 1 12.654 15.50 2 14.364 25.51 3 17.636 32.53 5 12.334 25.84 9 32.224 15.74 I want to find the euclidean distance of these coordinates from a particulat location saved in a list…
Shubham R
  • 7,382
  • 18
  • 53
  • 119
10
votes
4 answers

Pyspark euclidean distance between entry and column

I am working with pyspark, and wondering if there is any smart way to get euclidean dstance between one row entry of array and the whole column. For instance, there is a dataset like this. +--------------------+---+ | features|…
Yong Hyun Kwon
  • 359
  • 1
  • 3
  • 15
10
votes
4 answers

How to find the nearest neighbors of 1 Billion records with Spark?

Given 1 Billion records containing following information: ID x1 x2 x3 ... x100 1 0.1 0.12 1.3 ... -2.00 2 -1 1.2 2 ... 3 ... For each ID above, I want to find the top 10 closest IDs, based on Euclidean distance of…
10
votes
4 answers

How to calculate Euclidian distance between two points defined by matrix containing x, y?

I am very lost in Euclidean distance calculation. I have found functions dist2{SpatialTools} or rdist{fields} to do this, but they doesn´t work as expected. I suppose that one point has two coordinates in carthesian system, so [x,y]. To measure…
maycca
  • 3,848
  • 5
  • 36
  • 67
10
votes
3 answers

How to convert distance into probability?

Сan anyone shine a light to my matlab program? I have data from two sensors and i'm doing a kNN classification for each of them separately. In both cases training set looks like a set of vectors of 42 rows total, like this: [44 12 53 29 35 30 49; …
9
votes
3 answers

pdist2 equivalent in MATLAB version 7

I need to calculate the euclidean distance between 2 matrices in matlab. Currently I am using bsxfun and calculating the distance as below( i am attaching a snippet of the code ): for i=1:4754 test_data=fea_test(i,:); d=sqrt(sum(bsxfun(@minus,…
bhavs
  • 2,091
  • 8
  • 36
  • 66
1
2
3
62 63