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.

euclidean-distance
Filter by
Sorted by
Tagged with
2 votes
2 answers
6k views

Apply function to each element in 3 lists of tuples to get 1 resultant list python3

I am trying to calculate a resultant acceleration from x, y, z accelerations. I have written a function that does this when manually inputting the x,y,z coordinates. def Euclidean_norm(x,y,z): ...
Romesh Tirimanna's user avatar
2 votes
2 answers
95 views

Loop on a data frame with considering the types of the values

I have a large data set of coordinates and I want to calculate the Euclidean distance among them. The sample of that would be like this: df <- data.frame("name" = c("a","b","c","a","e"), "type" = ...
minoo's user avatar
  • 565
2 votes
2 answers
436 views

How to get minimum values in dataframe below a certain threshold?

I have 2 dataframes in pandas containing locational information of cars and trees. df1 x y car 3 216 13 4 218 12 ...
UserR6's user avatar
  • 503
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
2k views

Calculate average weighted euclidean distance between values in numpy

I searched a bit around and found comparable questions/answers, but none of them returned the correct results for me. Situation: I have an array with a number of clumps of values == 1, while the rest ...
Curlew's user avatar
  • 1,034
2 votes
1 answer
2k views

Substitute function of bwdist in C++

I am implementing a code of Matlab in C++. In Matlab they have used bwdist to calculate the euclidean distance. I am using the function distanceTransform to get the same result as in Matlab, but the ...
hawkeye's user avatar
  • 349
2 votes
1 answer
5k views

Euclidean Distance between Scipy Sparse Matrix and Sparse Vector

I am working on a KNN algorithm for a university assignment and at the moment I'm working on finding the Euclidean distance between each of the training vectors stored as a Scipy lil_matrix (due to ...
Lincoln's user avatar
  • 85
2 votes
2 answers
3k views

How can I return coordinates inside a radius in pure PHP? (without MySQL)

I've been doing this in MySQL for years, but how can I do this in PHP? Example CoordinateArray: http://pastebin.com/grVsbgL9 I'd like to return all the coordinates within 100 miles of a given ...
Ryan's user avatar
  • 15k
2 votes
1 answer
111 views

Average distance within group in pandas

I have a dataframe like this df = pd.DataFrame({ 'id': ['A','A','B','B','B'], 'x': [1,1,2,2,3], 'y': [1,2,2,3,3] }) The output I want is the average distance for each point in the group, ...
d_frEak's user avatar
  • 440
2 votes
2 answers
524 views

Get most similar words for matrix of word vectors

So I computed a matrix of word vectors manually using keras which looks like this: >>> word_embeddings 0 1 2 3 movie 0.007964 0.004251 -0....
Zwiebak's user avatar
  • 354
2 votes
1 answer
963 views

Clustering in Mixed Data Types

Why can't we use the Eculidean Distance for Clustering of Categorical Variables and Why we use Gower Distance for the clustering of Categorical Variables. I am just looking for a simple logic and ...
Karan sehgal's user avatar
2 votes
1 answer
1k views

R: results differ when calculating Euclidean distance between two vectors with different methods

Suppose that I have two vectors. x1 = c(-1, 2, 3) x2 = c(4, 0, -3) To calculate the Euclidean distance, I used three different ways 1- The built function norm s = cbind(x1, x2) norm(s, "2") #[1] 5....
jeza's user avatar
  • 299
2 votes
1 answer
2k views

Euclidean distance using intrinsic instruction

For a research project, I need to compute a lot of Euclidean distances, where certain dimensions must be selected and others discarded. In the current state of the program, the array of selected ...
Deadloop's user avatar
2 votes
2 answers
4k views

Understand normalized squared euclidean distance?

I'm trying to understand the normalized squared euclidean distance formula from the Wolfram documentation: 1/2*Norm[(u-Mean[u])-(v-Mean[v])]^2/(Norm[u-Mean[u]]^2+Norm[v-Mean[v]]^2) I searched around ...
Luca Zenesini's user avatar
2 votes
2 answers
280 views

Efficiently updating distance between points

I have a data set that has n rows (observations) and p columns (features): import numpy as np from scipy.spatial.distance import pdist, squareform p = 3 n = 5 xOld = np.random.rand(n * p).reshape([n, ...
ahoosh's user avatar
  • 1,360
2 votes
3 answers
8k views

Euclidean distances (python3, sklearn): efficiently compute closest pairs and their corresponding distances

I'm given a 2-D numpy array X consisting of floating values and need to compute the euclidean distances between all pairs of rows, then compute the top k row indices with the smallest distances and ...
user3280193's user avatar
2 votes
1 answer
3k views

Distance metrics in Scikit Learn

I was looking at some of the distance metrics implemented for pairwise distances in Scikit Learn. They include ‘cityblock’ ‘euclidean’ ‘l1’ ‘l2’ ‘manhattan’ Now I always assumed (based e.g. on here ...
patrick's user avatar
  • 4,643
2 votes
2 answers
707 views

Remove Elements of matrix by eucledian distance

I have an mxn matrix with E nonzero elements. The coordinates of the nonzeros are already available in an Ex2 vector. I'd like to check if the minimum Euclidean distance between every pair of ...
Mr Vinagi's user avatar
  • 410
2 votes
1 answer
1k views

Euclidean distance among dictionary elements

I am trying to compute the euclidean distance among the dictionary elements as shown below #!/usr/bin/python import itertools from scipy.spatial import distance def Distance(data): for subset ...
gaetano's user avatar
  • 887
2 votes
4 answers
3k views

Euclidean distance between np arrays

I have two numpy arrays a and b: a and b are the same dimensions, a could be a different size than b. For instance: a = [[1,2], ..., [5,7]] b = [ [3,8], [4,7], ... [9,15] ] Is there an easy ...
Mike El Jackson's user avatar
2 votes
1 answer
2k views

Distance between two cells in a 2D matrix

I have a 2D matrix represented as a vector of values, an index representing the first cell and a pair of coordinate representing the second cell. vector<double> matrix; auto index = 10; auto ...
Nick's user avatar
  • 10.4k
2 votes
1 answer
1k views

relabeling pixels based on distance between object's centerline and boundary

I've a binary image containing an object as illustrated in the figure below. The centerline of the object is depicted in red. For each pixel belonging to the object, I would like to relabel it with a ...
Tin's user avatar
  • 1,006
2 votes
1 answer
2k views

Calculating Squared Euclidean distance

I have an exe which return an array of 16elements.I have to pass this array to Mysql using php to calculate the Euclidean distance.My table in MySQL is in the form. id |img_id | features_1|...
user1583647's user avatar
  • 1,235
2 votes
1 answer
895 views

Calculate distance matrix for 3D points

I have the lists xA, yA, zA and the lists xB, yB, zB in Matlab. The contain the the x,y and z coordinates of points of type A and type B. There may be different numbers of type A and type B points. I ...
EXIT_FAILURE's user avatar
2 votes
3 answers
82 views

Euclidean distant for NON-CONSECUTIVE classes of factors iterated by groups

This question is an extension of this question. Euclidean distant for distinct classes of factors iterated by groups The same explanations from the previous question apply here as well. I want to ...
lovestacksflow's user avatar
2 votes
2 answers
1k views

Adjacency Matrix from Numpy array using Euclidean Distance

Can someone help me please on how to generate a weighted adjacency matrix from a numpy array based on euclidean distance between all rows, i.e 0 and 1, 0 and 2,.. 1 and 2,...? Given the following ...
Refka's user avatar
  • 55
2 votes
1 answer
2k views

How to calculate distance between two person using python opencv?

I am working on a project where I have to calculate the distance between the detected persons in live video feed. To do this I am following the below pipeline: 1. Detect person using MobilenetSSD ...
S Andrew's user avatar
  • 6,268
2 votes
1 answer
448 views

Calculate Euclidean distance between points with rolling function in data.table

I have a data.table with transects in different areas, coordinates x and y are projected as UTM 36S. How can I calculate the (Euclidean) distance between consecutive points with data.table, per area, ...
Henk's user avatar
  • 3,656
2 votes
1 answer
1k views

How to calculate the euclidean distance between neighbors in networkx using x,y coordinates automatically and find the minimum spanning tree

So far I calculate the euclidean distance between the neighbors manually. But I need help on our to calculate the distance automatically in the code. My code so far is: import networkx as nx ...
Elvissmog's user avatar
2 votes
1 answer
83 views

Permutation of euclidean distances between 13 row indexes in R

I have 13 Area of Interests (AOIs) with x and y values for each test image. How can I get all possible combination of euclidian distance between pairs of AOIs, ((x-xi)+(y-yi))^(1/2)? Ultimately I am ...
Hyokstayo's user avatar
2 votes
1 answer
403 views

How to select n objects from a set of N objects, maximizing the sum of pairwise distances between them

You have a set of N=400 objects, each having its own coordinates in a, say, 19-dimensional space. You calculate the (Euclidean) distance matrix (all pairwise distances). Now you want to select n=50 ...
user6376297's user avatar
2 votes
1 answer
46 views

Distance matrix to reshaped vector of distances sorted by positions

I have a data frame of 5 items, as follows: df = structure(list(item1 = c(1, 1, 1, 1, 2, 2, 2, 3, 3, 4), item2 = c(0, 2, 3, 4, 0, 3, 4, 0, 4, 0)), row.names = c(NA, -10L), class = c("tbl_df", "tbl",...
Omry Atia's user avatar
  • 2,443
2 votes
1 answer
2k views

How to calculate euclidean distance of each row in a dataframe to a constant reference array

I have a dataframe which is created from parquet files that has 512 columns(all float values). I am trying to calculate euclidean distance of each row in my dataframe to a constant reference array. My ...
ozlemg's user avatar
  • 436
2 votes
1 answer
898 views

Compute the Euclidean distances between corresponding rows of 2 matrices

I have 2 matrices A and B, and I want to compute the Euclidean distances between 1st row of A and 1st row of B, 2nd row of A and 2nd row of B, etc. I know I can use rdist function to compute the ...
user5054's user avatar
  • 1,076
2 votes
1 answer
716 views

How to calculate sum of Euclidean distances from one datapoint to all other datapoints from pandas dataframe?

I have the following pandas dataframe: import pandas as pd import math df = pd.DataFrame() df['x'] = [2, 1, 3] df['y'] = [2, 5, 6] df['weight'] = [11, 12, 13] print(df) x y weight 0 ...
arizamoona's user avatar
2 votes
4 answers
5k views

Find shortest distance between multiple points

Imagine a small dataset of xy coordinates. These points are grouped by a variable called indexR, there are 3 groups in total. All xy coordinates are in the same units. The data looks approximately ...
Quinn's user avatar
  • 419
2 votes
1 answer
2k views

Why is sklearn faster on CPU than Theano on GPU?

I've compared processing time with theano(CPU), theano(GPU) and Scikit-learn(CPU) using Python. But, I got strange result. Here look at the graph that I plot. Processing Time Comparison: you can see ...
Holden's user avatar
  • 23
2 votes
1 answer
361 views

What's the difference between these np.linalg.norm methods

I have these two methods which are from a KNN implementation. I gather that they are two distance measurements, however I do not understand how they differ. I've tried looking up the method but haven'...
Anthony J's user avatar
  • 561
2 votes
3 answers
5k views

How to use Euclidean Distance to calculate similarity values for the three pairs of documents

I am trying to work on this question however I am not sure how to use the Euclidean equation to find the solution. Question: Following are keywords, frequencies, and token counts from 3 other ...
Harry Willams's user avatar
2 votes
1 answer
1k views

Vectorizing euclidean distance computation - NumPy

my question regards the vectorization of my code. I have one array that holds 3D-coordinates and one array that holds the information of edges that connect the coordinates: In [8]:coords Out[8]: ...
Ozzycalifornia's user avatar
2 votes
1 answer
2k views

Calculate Rao's quadratic entropy

Rao QE is a weighted Euclidian distance matrix. I have the vectors for the elements of the d_ijs in a data table dt, one column per element (say there are x of them). p is the final column. nrow = S. ...
JerryN's user avatar
  • 2,456
2 votes
2 answers
1k views

Find which points are within a given distance of each point

I have a dataframe that has a list of places and their geographical locations in UTM (Universal Transverse Mercator) coordinates. It looks something like this: Place X_UTM Y_UTM 1 574262.0 ...
Leandro Zipitria's user avatar
2 votes
1 answer
778 views

Calculating 3D Euclidean Distance without overflows or underflows

Calculating 3D Euclidean Distance without overflows or underflows Hello there, I have written code to calculate the 3D Euclidean Distance between two vectors. I know this is a pretty common ...
Luigi Castelli's user avatar
2 votes
3 answers
686 views

Subsequent time-series matching

I've been stuck with subsequent matching of time-series in MATLAB (I'm new to it). I have two time-series: A (of length a) and B (of length b). Assume that a is much larger than b. The task is to ...
Max's user avatar
  • 471
2 votes
1 answer
1k views

How to find Euclidean Norm of rows of a matrix with BLAS?

I have an matrix M that I need to calculate its Euclidean Norm of its rows. Is it possible to use the efficiency of BLAS library for such purpose?
erogol's user avatar
  • 13.4k
2 votes
4 answers
9k views

How do I create a simliarity matrix in MATLAB?

I am working towards comparing multiple images. I have these image data as column vectors of a matrix called "images." I want to assess the similarity of images by first computing their Eucledian ...
Vivek Subramanian's user avatar
2 votes
2 answers
82 views

How to compute the Euclidean distance between two complex matrix by vectorization?

X=[x_1,x_2,...,x_N] is a [S,N] complex matrix. For example, S=3 and x_1=[1+2j,2+3j,3+4j]'. D is the distance matrix of X, which means D(i,j) is the Euclidean distance between x_i and x_j. my code: D = ...
Jie zhou's user avatar
2 votes
1 answer
56 views

How to Divide Relative Distance into Three Equidistant Regions in MATLAB?

I have two distance maps. One refers to the distance from one point to the outside (starting at 0, ending at a high number reflecting distance from one point). The other is basically equal and ...
CamH's user avatar
  • 25
2 votes
1 answer
50 views

Calculate distance with multiple starting coordinates

I calculated the travelled distance called distance_m per date with the function points_in_circle for two ID's called HEX_Tag_ID. The coordinates that I put in the function are based on the Datum &...
Pepijn95's user avatar
  • 321
2 votes
2 answers
1k views

Euclidean distance or cosine similarity between columns with vectors in PySpark

I have a Spark dataframe in the following form: > df1 +---------------+----------------+ | vector1| vector2| +---------------+----------------+ |[[0.9,0.5,0.2]]| [[0.1,0.3,0.2]]| |[...
Hilary's user avatar
  • 485

1
3 4
5
6 7
19