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
950
questions
4
votes
4
answers
2k
views
What is the best way to check all pixels within certain radius?
I'm currently developing an application that will alert users of incoming rain. To do this I want to check certain area around user location for rainfall (different pixel colours for intensity on ...
4
votes
1
answer
131
views
Wrong Euclidean distance H2O calculations R
I am using H2O with R to calculate the euclidean distance between 2 data.frames:
set.seed(121)
#create the data
df1<-data.frame(matrix(rnorm(1000),ncol=10))
df2<-data.frame(matrix(rnorm(300),...
4
votes
2
answers
2k
views
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 ...
4
votes
2
answers
3k
views
GLSL Distance Field transparency
I am after smooth texture based outline effect in OpenGL. So far I tried mostly all kinds of edge detection algorithms which result mostly in crude and jagged outlines. Then I read about Distance ...
4
votes
2
answers
7k
views
Quickest way to calculate the Euclidean-Distance between two points in N-Dimensional space
I have to calculate the Euclidean Distance between two points in N-Dimensional space, and speed is crucial. I have two C style float arrays representing the two points in N-Dimensional space.
The ...
4
votes
1
answer
2k
views
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 ...
4
votes
0
answers
576
views
Calculate Euclidean distance using Painless in Elasticsearch
I would like to sort results from Elasticsearch according to Euclidean distance between document double array and double array from "params". For now I am using my own solution that calculate this ...
4
votes
3
answers
4k
views
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 ...
4
votes
1
answer
2k
views
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 ...
4
votes
2
answers
6k
views
A* with manhattan distance or euclidean distance for maze solving?
I have obtained all the possible paths of maze through image processing. Now, I want to use A* algorithm in order to find shortest path of maze. However, I am confused as to whether euclidean distance ...
3
votes
4
answers
881
views
Pairwise weighted distance vectorization
The following efficient and vectorized Matlab code computes the Weighted Euclidean Distance between 2 sets of points A and B using a weight vector WTS (1 weight for each dimension; same weights for ...
3
votes
3
answers
23k
views
How to calculate normalized euclidean distance on two vectors?
Let's say I have the following two vectors:
x = [(10-1).*rand(7,1) + 1; randi(10,1,1)];
y = [(10-1).*rand(7,1) + 1; randi(10,1,1)];
The first seven elements are continuous values in the range [1,10]....
3
votes
3
answers
12k
views
Euclidean Distance
I have two points
x1 = (a1,b1,c1,d1,e1); //5 dimensional point
x2 = (a2,b2,c2,d2,e2); //5 dimensional point
So is this right way to calculate the euclidean dist?
d = sqrt(sqr(a1-a2)+sqr(...
3
votes
1
answer
7k
views
Calculate distance between two descriptors
I'm trying to calculate the distance (Euclidean or hamming) between two descriptors already calculated. The problem is I don't want to use a matcher, I just want to calculate the distance between two ...
3
votes
1
answer
2k
views
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. ...
3
votes
2
answers
5k
views
Finding squared distances beteen n points to m points in numpy
I have 2 numpy arrays (say X and Y) which each row represents a point vector.
I would like to find the squared euclidean distances (will call this 'dist') between each point in X to each point in Y.
I ...
3
votes
3
answers
3k
views
Euclidean distance returning strange results
im writing a program to compare two images against each other based on color and im using the Euclidean distance algorithm however when i run it and pass in two images i get one distance and then when ...
3
votes
2
answers
3k
views
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 ...
3
votes
2
answers
956
views
Computing Euclidean distances between subsequent positions
I have large data frames consisting of pairs of X and Y coordinates, and wish to calculate the Euclidean distances between consecutive coordinates (minimal size is around 2000 pairs of coordinates).
...
3
votes
4
answers
7k
views
How to find most optimal number of clusters with K-Means clustering in Python
I am new to clustering algorithms. I have a movie dataset with more than 200 movies and more than 100 users. All the users rated at least one movie. A value of 1 for good, 0 for bad and blank if the ...
3
votes
3
answers
8k
views
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....
3
votes
1
answer
6k
views
Distance between two sets of points [duplicate]
So after looking at various Questions asked here on stackoverflow I'm still not able to wrap my head around the dist function in R or maybe even a distance matrix in general.
So I have two dataframes ...
3
votes
1
answer
15k
views
Python 'TypeError': 'Generator' object is not subscriptable
I'm trying to perform a simple Euclid example in Python but receive the error mentioned in the title. The code is as follows:
def gcd1(a,b):
""" the euclidean algorithm """
while a:
...
3
votes
2
answers
430
views
R: calculate Euclidean distance between two raster layers pixels
I have two raster layers for same area. I need to find the Euclidean distance between cell of coarse resolution raster and cell of fine resolution raster that fall within each cell of the pixels from ...
3
votes
3
answers
3k
views
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 ...
3
votes
3
answers
1k
views
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' :...
3
votes
1
answer
1k
views
Minimal edge-to-edge euclidean distance between labeled components in numpy array
I have a number of distinct forms in large numpy arrays and I want to calculate the edge-to-edge euclidean distance between them using numpy and scipy.
Note: I did a search and this is different ...
3
votes
1
answer
108
views
How can I generate n points with euclidan distance less than d from X
Let's say I have a point:
point <- c(1, 2)
How can I generate 10 points with euclidan distance from point lower than some choosen value, e.g. 3.
In other words: how can I generate set of points in ...
3
votes
2
answers
7k
views
fastest way to find euclidean distance in python
I have 2 sets of 2D points (A and B), each set have about 540 points. I need to find the points in set B that are farther than a defined distance alpha from all the points in A.
I have a solution, ...
3
votes
3
answers
2k
views
euclidean distance between vectors grouped by other variable in SPSS, R or Excel
I have a dataset containing something like this:
case,group,val1,val2,val3,val4
1,1,3,5,6,8
2,1,2,7,5,4
3,2,1,3,6,8
4,2,5,4,3,7
5,1,8,6,5,3
I'm trying to compute programmatically the Euclidean ...
3
votes
2
answers
406
views
Path that gets within given distance of each point in order
I have an ordered list of points in a 2D plane. I'd like to find the shortest route such that it gets at least within distance X (or closer) from each point, in the given order. How do I find this ...
3
votes
1
answer
2k
views
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 ...
3
votes
1
answer
657
views
Finding euclidean difference between coordinates in numpy
I am trying to calculate the difference between coordinates using numpy using following code :
X = np.random.random((1000, 3))
# using broadcasting to calculate to find pairwise diffrence
diff = X....
3
votes
2
answers
3k
views
Creating a 2-dimensional Numpy array with the euclidean distance from the center
I'm trying to create a 2-dimensional array in Scipy/Numpy where each value represents the euclidean distance from the center. It's supposed to have the same shape as the first two dimensions of a 3-...
3
votes
4
answers
3k
views
Alternative to using squareform (Matlab)
At the moment i am using the pdist function in Matlab, to calculate the euclidian distances between various points in a three dimensional cartesian system. I'm doing this because i want to know which ...
3
votes
2
answers
1k
views
Euclidian Distances between points
I have an array of points in numpy:
points = rand(dim, n_points)
And I want to:
Calculate all the l2 norm (euclidian distance) between a certain point and all other points
Calculate all pairwise ...
3
votes
2
answers
131
views
Generate P random N-dimensional points from list of ALL possible pairwise distances
I would like to generate random N-dimensional points with the constraint of having precise Euclidean distances (known) between each other.
Number of points P = 100
Number of dimensions of the ...
3
votes
1
answer
1k
views
Distance calculation in mongodb aggregate using cosine
I am saving face embedding as numpy array in mongodb and using this aggrigate to find distance between to array using euclidean algorithm.
Can someone please help to calculate distance using cosine?
...
3
votes
2
answers
3k
views
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 ...
3
votes
2
answers
978
views
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),
...
3
votes
2
answers
3k
views
5 nearest neighbors based on given distance in r
I have the following dataset:
id x y age
1 1745353 930284.1 30
2 1745317 930343.4 23
3 1745201 930433.9 10
4 1745351 930309.4 5
5 1745342 930335.2 2
6 ...
3
votes
1
answer
3k
views
Calculate euclidean distance in a faster way
I want to calculate the euclidean distances between rows of a dataframe with 30.000 observations. A simple way to do this is the dist function (e.g., dist(data)). However, since my dataframe is large, ...
3
votes
1
answer
7k
views
Distance between nodes using python networkx
I am new to NetworkX, and I need to find the distance between two nodes. I have given it a go, but most of the searches lead to the DFS, Dijkstra, etc. approaches, which is not my point. I only want ...
3
votes
1
answer
617
views
Calculate Distance Metric between Homomorphic Encrypted Vectors
Is there a way to calculate a distance metric (euclidean or cosine similarity or manhattan) between two homomorphically encrypted vectors?
Specifically, I'm looking to generate embeddings of documents ...
3
votes
2
answers
228
views
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 ...
3
votes
1
answer
1k
views
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, ...
3
votes
1
answer
912
views
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 = []...
3
votes
1
answer
359
views
Clustering pictures by time and location
I'm trying to cluster pictures according to the location they were taken and the time they were taken. My clustering algorithm requires me to define a distance function between every two points, (in ...
3
votes
2
answers
3k
views
Javascript object color change dynamically?
Here's the code to change color of balls to red when two balls collide.I'm almost there but but i don't seem to find the fault because one ball is not changing the color.Please help me out guys!!
/...
3
votes
1
answer
529
views
Binary Tree using int array as key (Euclidean distances)?
Have written a Binary Search Tree that stores data on ships, the key for the search is their acoustic signature.
When searching the tree I want to return either a ship with the correct signature or ...