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

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 vectors, one from each set, that has the minimum…
5
votes
2 answers

r distance between rows

I apologize this is my attempt at redeeming myself after a disastrous earlier attempt . Now I have a bit more clarity. So here I go again. My goal is to find rows that are similar. So first I am interested in calculating the distance between rows.…
Emily Fassbender
  • 413
  • 5
  • 15
5
votes
1 answer

Best way to identify dissimilarity: Euclidean Distance, Cosine Distance, or Simple Subtraction?

I'm new to data science and am currently learning different techniques that I can do with Python. Currently, I'm trying it out with Spotify's API for my own playlists. The goal is to find the most dissimilar features between two different playlist.…
5
votes
2 answers

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 distance with 2 nested for loops (O(m^2)) but this…
user3243499
  • 2,953
  • 6
  • 33
  • 75
5
votes
1 answer

Calculating Euclidian Norm in Pytorch.. Trouble understanding an implementation

I've seen another StackOverflow thread talking about the various implementations for calculating the Euclidian norm and I'm having trouble seeing why/how a particular implementation works. The code is found in an implementation of the MMD metric:…
Fosa
  • 562
  • 5
  • 15
5
votes
0 answers

Getting distance to the hyperplane from sklearn's svm.svc

I'm currently using svc to separate two classes of data (the features below are named data and the labels are condition). After fitting the data using the gridSearchCV I get a classification score of about .7 and I'm fairly happy with that number.…
5
votes
7 answers

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 distance between any number from different buckets in…
oleksii
  • 35,458
  • 16
  • 93
  • 163
5
votes
2 answers

Distance matrix from two separate data frames

I'd like to create a matrix which contains the euclidean distances of the rows from one data frame versus the rows from another. For example, say I have the following data frames: a <- c(1,2,3,4,5) b <- c(5,4,3,2,1) c <- c(5,4,1,2,3) df1 <-…
h7681
  • 355
  • 4
  • 13
5
votes
4 answers

Vectorize mask of squared euclidean distance in Python

I'm running code to generate a mask of locations in B closer than some distance D to locations in A. N = [[0 for j in range(length_B)] for i in range(length_A)] dSquared = D*D for i in range(length_A): for j in range(length_B): if…
ToneDaBass
  • 489
  • 1
  • 4
  • 11
5
votes
2 answers

How to implement callable distance metric in scikit-learn?

I'm using the clustering module in python's scikit learn, and I'd like to use a Normalized Euclidean Distance. There is no built-in distance for this (that i know of) Here's a list. So, I want to implement my own Normalized Euclidean Distance…
makansij
  • 9,303
  • 37
  • 105
  • 183
5
votes
5 answers

Calculating distance between two points in 3D

My assignment is to create main class in which I initialize the value of any point to be at (0,0,0) and to be able to access and mutate all three values (x,y,z) individually. To do this I have used getters and setters. My next task is to create a…
5
votes
3 answers

Java methods getting euclidean distance

public class Point { // Placeholders for xcoordinate, ycoordinate, and quadrants int xcoord = 0; int ycoord =0; double distance = 0.0; String quadrant = ("NW"); //moveUp changes the y coordinate void moveUp (int x) { int moveUp = ycoord +…
user3444564
  • 57
  • 1
  • 1
  • 6
5
votes
2 answers

Calculate Euclidean Distance within points in numpy array

I have 3D array as A = [[x1 y1 z1] [x2 y2 z2] [x3 y3 z3]] I have to find euclidean distance between each points so that I'll get output with only 3 distance between (row0,row1),(row1,row2) and (row0,row2). I have some code dist =…
DummyGuy
  • 425
  • 1
  • 8
  • 20
5
votes
1 answer

Finding euclidean distance in R{spatstat} between points, confined by an irregular polygon window

I'm trying to find the euclidean distance between two points, confined by an irregular polygon. (ie. the distance would have to be calculated as a route through the window given) Here is an reproducible example: library(spatstat) #Simple example of…
user3389288
  • 992
  • 9
  • 30
5
votes
2 answers

Fastest way to Calculate the Euclidian distance between 2 sets of vectors using numpy or scipy

OK I have recently discovered that the the scipy.spatial.distance.cdist command is very quick for solving a COMPLETE distance matrix between two vector arrays for source and destination. see: How can the euclidean distance be calculated with…
SoulNibbler
  • 149
  • 2
  • 4