All Questions
Tagged with euclidean-distance arrays
41
questions
27
votes
2
answers
38k
views
Is "norm" equivalent to "Euclidean distance"?
I am not sure whether "norm" and "Euclidean distance" mean the same thing. Please could you help me with this distinction.
I have an n by m array a, where m > 3. I want to calculate the Eculidean ...
8
votes
1
answer
4k
views
einsum and distance calculations
I have searched for a solution to determine distances using einsum for numpy arrays that are not equal in their number of rows, but equal in columns. I have tried various combinations but the only ...
5
votes
2
answers
4k
views
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,...
4
votes
3
answers
16k
views
In Numpy, find Euclidean distance between each pair from two arrays
I have two arrays of 2D coordinate points (x,y)
a = [ (x1,y1), (x2,y2), ... (xN,yN) ]
b = [ (X1,Y1), (X2,Y2), ... (XN,YN) ]
How can I find the Euclidean distances between each aligned pairs (xi,yi) ...
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 ...
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
3
answers
3k
views
Calculating Euclidean distance of pairs of 3D points in matlab
I have an Nx3 array that contains N 3D points
a1 b1 c1
a2 b2 c2
....
aN bN cN
I want to calculate Euclidean distance in a NxN array that measures the Euclidean distance between each pair of 3D ...
3
votes
1
answer
784
views
Making an Euclidean Distance Matrix with Random Points in Python
I wrote a code that produces the desired number of points in a certain width and length range in the coordinate system. How can I calculate and tabulate the distance matrix of these points I produced ...
2
votes
2
answers
227
views
Compute the difference matrix between a matrix and another matrix in MATLAB
Given a matrix A in matlab with:
3 1
4 5
7 8
and another matrix B which could be referred to as some reference points (each row is reference point that is to be compared to each row of A),
1 ...
2
votes
2
answers
1k
views
Calculating pairwise spatial distances in periodic 2D lattice
I've been searching in vain for a solution to compute spatial distances between discrete, equidistant square sites on a lattice of periodic/wrapped edges. For example, setting adjacent sites to be 2 ...
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 ...
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, ...
2
votes
1
answer
200
views
For loop on two arrays of points
I have two arrays of points: list1 with list1.shape = [N, 3] and list2 with list2.shape = [M, 3]. Within N, M: the total number of point, (x, y, z) are 3 coordinates in 3D.
Now I want to check if ...
1
vote
4
answers
3k
views
Numpy distance calculations of different shaped arrays
Not sure I titled this well, but basically I have a reference coordinate, in the format of (x,y,z), and a large list/array of coordinates also in that format. I need to get the euclidean distance ...
1
vote
2
answers
102
views
Find the nearest set in multiple numpy arrays
I have 3 numpy arrays, i.e. x,y,z, which each have equal length. Also, matching indices between the 3 numpy arrays form a single set, e.g. (x[i],y[i],z[i]). Given x,y,z as known arrays and an ...
1
vote
1
answer
1k
views
Efficient way to compute multiple euclidean distances Matlab
I am training my own self organizing map to cluster colorvalues. Now I want to make some sort of a U-matrix to show euclidean distances between the nodes and their direct neighbors. My problem now is, ...
1
vote
0
answers
221
views
Pyspark Euclidean and Cosine distance between 2 arrays
I have a pyspark data frame with data shaped like the following (data made up):
Dataframe
I would like to calculate various distance metrics (such as cosine, euclidean) between the 2 vectors, vec1 ...
1
vote
3
answers
1k
views
how to calculate Manhattan distance (or L1/ cityblock) for two 2D array?
For 1D vector/array it's easier. For example:
array1 = [1, 2, 3]
array2 = [1, 1, 1]
manhattan distance will be: (0+1+2) which is 3
import numpy as np
def cityblock_distance(A, B):
result = np....
1
vote
1
answer
163
views
How to recursively discretize segments if segment length is higher than a specific value
In order to improve the efficiency of a python script, I am trying to convert a script based on a lot of "for loop" operations on a points cloud thanks to Numpy to speed up the process.
In a nutshell,...
1
vote
0
answers
164
views
Python: Reshaping arrays and lists
I have a numpy ndarray object with the following shape:
(3, 256, 170, 256).
So, basically this represents an array of 3-dimensional vectors. The dimension of the vector is the first element as it ...
1
vote
2
answers
4k
views
XB must be a 2-dimensional array in cdist
I have two 3D array as
clusters = [array([[ 0.42199652, -0.14364404, 0.21290469]]),
array([[ 5.80084178e-05, 1.20779787e-02, -2.65970238e-02],
[ -1.36810406e-02, 6.85722519e-02, -2....
0
votes
1
answer
11k
views
Euclidean Distance between 2 Vectors Implementation
I working through a few exercises from an academic programing book. The task is to implement 2 vectors and calculate the Euclidean distance between thereof. No this is not Home Work, rather self ...
0
votes
1
answer
589
views
calculating euclidean distance of 2 byte arrays java
I have 2 main images and I want to compare a set of other images to them.
What I do is computing the byte array of those two images and then compare those 2 with the current image being processed. ...
0
votes
2
answers
3k
views
euclidean distance between values in a array - result ordered asc in new array [closed]
I'm looking for a fast way to compute euclidean distance of all values in a array. The Result should be in a new array ordered ascending with the two used "partners" for calculation.
eg:
a = [[2,4,5]...
0
votes
2
answers
1k
views
How to apply the distance formula to a list of [x,y] coordinates in python
In order to solve the Traveling Salesman Problem (TSP) using a genetic algorithm, I am randomly generating a list of Z points on an N by N grid:
field = [random.sample(range(N), 2) for x in range(Z)]
...
0
votes
2
answers
395
views
Argmin with the Euclidean distance condition
In Python, I have a vector v of 300 elements and an array arr of 20k 300-dimensional vectors. How do I get quickly the indices of the k closest elements to v from the array arr?
0
votes
1
answer
253
views
Calculation looping through dataframe of lists and list of arrays
I want to calculate the Euclidean distance using a list of arrays.
import numpy as np
import pandas as pd
from scipy.spatial import distance
#Dataframe
data = [np.array([[1, 2], [1, 3], [1, 1]]),
...
0
votes
2
answers
122
views
Finding the smallest number in array list java
So I have some code which is finding the distance between a series of points. One method uses the euclidean distance and is working fine, the other is using Manhattan and I don't know why it isn't ...
0
votes
1
answer
2k
views
Comparing each set of a two-dimensional array to determine largest distance
So I have a set of elements in a 2d array, and I am trying to determine the largest distance between coordinates.
I have made a loop to go through each element, but I can't figure out how to only ...
0
votes
4
answers
3k
views
Euclidean distance between the coordinates in the array
I calculate euclidean distance in c#.
Point[] points = new Point[100];
I have the coordinates of the points I created in this array.I want to calculate the distance between all points.
for (int i = ...
0
votes
1
answer
3k
views
Euclidean Distance of two vectors with different length
I have a code for calculating euclidean distance like this :
for(int j=0;j<inputdimension;j++){
distance += Math.pow((vector1[j] - vector2.get(j)), 2);
}
and i've an example of data ...
0
votes
1
answer
5k
views
Calculating distance between two elements only in the array in python
So I have two questions: First I'm trying to print my array that contains 1004 elements but it's printing only the first 29 elements and then jumping to 974 to continue printing. How can I get the ...
0
votes
1
answer
2k
views
Pandas - convert columns to grouped array coordinates
I have a DataFrame of (x, y) coordinates that I would like to transform into array's to perform pairwise distance calculations on.
df = pd.DataFrame({'type': ['a', 'a', 'a', 'b', 'b', 'c', 'c', '...
0
votes
1
answer
209
views
Euclidean distance between features vectors
I have a dataset such as: `
team y
A African Dance [[1.059685349464416, 0.328705966472625, 0.3115...
Ballet [[0.486603736877441, 1.678925514221191, 0.0157...
...
0
votes
1
answer
112
views
Finding the most similar index in an array using Euclidian distance
so I have an array and given a certain row, I want to output the most similar row using Euclidean distanceing? I know its in scipy.spatial.distance but I can't figure out how to implement it!
so e.g:
...
0
votes
1
answer
1k
views
What is the fastest way to apply np.linalg.norm() (python) to each element of a 2d numpy array and a given value?
I want to compute the L2 norm between a given value x and each cell of a 2d array arr (which is currently of size 1000 x 100. My current approach:
for k in range(0, 999):
for l in range(0, ...
0
votes
1
answer
337
views
Selecting closest values by Euclidian distance from the mean from a numpy array
I'm sure there's a straightforward answer to this, but I'm very much a Python novice and trawling stackoverflow is getting me tantalisingly close but falling at the final hurdle, so apologies. I have ...
0
votes
0
answers
159
views
Extract numpy array of Euclidean distances
I am trying to extract a python numpy array of euclidean distances. I already have the values properly imported and distances calculated, and they are already in a visual heat map, but I do not know ...
0
votes
1
answer
761
views
Creating a structure point and then calculating distance between two points
I need some help figuring how do i create a structure point.
I need two fields x and y then I want to create a function that calculates the distance between these two points.
What I have right now ...
-1
votes
1
answer
684
views
Distance calculation for coordinates called from a file(Python2.7)
I'm trying to read coordinates from a file and find distance between each two respective atoms in the file.
I want to have the calculated distance in one column and the respective atom names in the ...
-2
votes
1
answer
51
views
How to create spaces in a textbox?
I have a vb net program to take a binary value in the image. This syntax produces
111110
on textbox3.text. I want no spaces at textbox3.text
1 1 1 1 1 0
Dim x, y As Integer
Dim ...