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
3
votes
2 answers

How to get m pair of points among n points that have the largest distance between them

Say I have the following points defined in a one dimensional space: x = np.array([[0.70710678], [0.70710678], [0. ], [1.41421356]]) I want to get m pair of points among these n points that have the…
Alejandro
  • 879
  • 11
  • 27
3
votes
3 answers

Distance between points on haskell

im new to haskell and i have to do a function that takes a list and calculates the distance recursively. For example: distance [(0,0),(2,0),(2,5)] ->7 distance [(1,1),(3,4)] ->3.6055512 I made the distance between just two points like…
John
  • 45
  • 5
3
votes
3 answers

Calculate euclidean distance between groups in a data frame

I have weekly data for various stores in the following form: pd.DataFrame({'Store':['S1', 'S1', 'S1', 'S2','S2','S2','S3','S3','S3'], 'Week':[1, 2, 3,1,2,3,1,2,3], 'Sales' : [20,30,40,21,31,41,22,32,42],'Cust_count' :…
bakas
  • 323
  • 2
  • 11
3
votes
3 answers

measuring similarity between two rgb images in python

I have two rgb images of same size, and I would like to compute a similarity metric. I thought of starting out with euclidean distance: import scipy.spatial.distance as dist import cv2 im1 = cv2.imread("im1.jpg") im2 = cv2.imread("im2.jpg") >>…
HappyPy
  • 9,839
  • 13
  • 46
  • 68
3
votes
1 answer

How to use apply function to calculate the distance between two matrices

I'm trying to calculate the euclidean distance between two matrices. I have already achieved that using 2 for loops but trying to vectorize the calculation to speed up. I'm using pdist as a benchmark to valid if the distance is calculated…
Ray
  • 59
  • 5
3
votes
0 answers

How to calculate euclidean distance of a column with all the sublist of another column with respect to grouping in pandas dataframe?

I have following dataframe, mac1 mac2 uuid val refVal 0 ac233fc01403 ac233f26492b e2c56 [-42, -44] [[-45,…
anu010291
  • 85
  • 1
  • 7
3
votes
2 answers

Euclidean distance between two objects

First of all I know what the Euclidean distance is and what it does or calculates between two vectors. But my question is about how to calculate the distance between two class objects for example in Java or any other OOP-Language. I read pretty…
Markus G.
  • 1,620
  • 2
  • 25
  • 49
3
votes
2 answers

euclidean distance calculation using Python and Dask

I'm attempting to identify elements in the euclidean distance matrix that fall under a certain threshold. I then take the positional arguments for this search and use them to compare elements in a second array (for sake of demonstration this array…
3
votes
1 answer

What is the most efficient way to compute the square euclidean distance between N samples and clusters centroids?

I am looking for an efficient way (no for loops) to compute the euclidean distance between a set of samples and a set of clusters centroids. Example: import numpy as np X = np.array([[1,2,3],[1, 1, 1],[0, 2, 0]]) y = np.array([[1,2,3], [0, 1,…
3
votes
1 answer

Does Euclidean Distance measure the semantic similarity?

I want to measure the similarity between sentences. Can I use sklearn and Euclidean Distance to measure the semantic similarity between sentences. I read about Cosine similarity also. Can someone explain the difference of those to measures and what…
3
votes
1 answer

Finding distance between elements of two different list

The code below finds the Euclidean distance between each element of list a and each element of list b. from scipy.spatial import distance a = [[1, 2, 3], [4, 5, 6]] b = [[10, 20]] Final_distance = [] for i in [j for sub in a for j in sub]: for…
An student
  • 392
  • 1
  • 6
  • 16
3
votes
1 answer

How to calculate weighted similarity with scipy.spatial.distance.cosine?

From the function definition: https://docs.scipy.org/doc/scipy/reference/generated/scipy.spatial.distance.cosine.html scipy.spatial.distance.cosine(u, v, w=None) but my codes got some errors: from scipy import spatial d1 = [3,5,5,3,3,2] d2 =…
3
votes
2 answers

Creating an equilateral triangle for given two points in the plane - Python

I have two points X = (x1,y1) and Y=(x2,y2) in the Cartesian plane. I need to find the third point Z = (x,y) such that these three points make an equilateral triangle. I'm calculating the Euclidean distance between two points using the following…
ccc
  • 574
  • 2
  • 9
  • 22
3
votes
2 answers

R, compute the smallest Euclidean Distance for two dataset, and label it automatically

I'm working with Euclidean Distance with a pair of dataset. First of all, my data. centers <- data.frame(x_ce = c(300,180,450,500), y_ce = c(23,15,10,20), center = c('a','b','c','d')) points <-…
s__
  • 9,270
  • 3
  • 27
  • 45
3
votes
1 answer

How can I calculate the distance between two points in Cartesian space while respecting Asteroids style wrap around?

I have two points (x1, y1) and (x2,y2) which represent the location of two entities in my space. I calculate the Euclidian distance between them using Pythagoras' theorem and everything is wonderful. However, if my space becomes finite, I want to…
hornairs
  • 1,707
  • 13
  • 20