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
7
votes
1 answer

Calculating euclidean distance between consecutive points of an array with numpy

I have an array which describes a polyline (ordered list of connected straight segments) as follows: points = ((0,0), (1,2), (3,4), (6,5), (10,3), (15,4)) points = numpy.array(points,…
heltonbiker
  • 26,657
  • 28
  • 137
  • 252
6
votes
2 answers

Matlab formula optimization: Radial Basis Function

z - matrix of doubles, size Nx2; x - matrix of doubles, size Nx2; sup = x(i, :); phi(1, i) = {@(z) exp(-g * sum((z - sup(ones([size(z, 1) 1]),:)) .^ 2, 2))}; this is a Radial Basis Function (RBF) for logistic regression. Here is the formula: I…
Yekver
  • 4,985
  • 7
  • 32
  • 49
6
votes
1 answer

trying to draw circles based on distance between points

I'm trying to draw some circles and I was sort of hoping they would intersect with some points, alas... library(maptools) library(plotrix) xy <- matrix(runif(20, min = -100, max = 100), ncol = 2) distance <- spDistsN1(xy, xy[1, ]) plot(0,0, xlim =…
Roman Luštrik
  • 69,533
  • 24
  • 154
  • 197
6
votes
1 answer

Calculate the euclidian distance between an array of points to a line segment in Python without for loop

I'm looking for a function to compute the euclidian distance between a numpy array of points with two coordinates (x, y) and a line segment. My goal is to have a result in under 0.01 sec for a line segment and 10k points. I already found a function…
Jérôme
  • 142
  • 2
  • 8
6
votes
5 answers

How to calculate Euclidean length of a matrix without loops?

It seems like the answer to this should be simple, but I am stumped. I have a matrix of Nx3 matrix where there 1st 2nd and 3rd columns are the X Y and Z coordinates of the nth item. I want to calculate the distance from the origin to the item. …
Miebster
  • 2,365
  • 4
  • 21
  • 27
6
votes
1 answer

Why cdist from scipy.spatial.distance is so fast?

I wanted to create a distance proximity matrix for 10060 records/ points, where each record/point has 23 attributes using euclidean distance as metric. I wrote code using nested for loops to calculate distance between each point(leading to…
Sushodhan
  • 400
  • 1
  • 6
  • 16
6
votes
4 answers

Sum of distances from a point to all other points

I have two lists available_points = [[2,3], [4,5], [1,2], [6,8], [5,9], [51,35]] and solution = [[3,5], [2,1]] I'm trying to pop a point in available_points and append it to solution for which the sum of euclidean distances from that point, to all…
jfran
  • 143
  • 1
  • 7
6
votes
2 answers

Creating a distance matrix from a list of coordinates in R

I have a csv file with a list of co-ordinate positions for over 2000 farms, with the following structure; FarmID | Latidue | Longitude | ------ |---------|-----------| 1 | y1 | x1 | 2 | y2 | x2 | 3 | y3 …
sruby52
  • 83
  • 1
  • 6
6
votes
3 answers

Numpy: find the euclidean distance between two 3-D arrays

Given, two 3-D arrays of dimensions (2,2,2): A = [[[ 0, 0], [92, 92]], [[ 0, 92], [ 0, 92]]] B = [[[ 0, 0], [92, 0]], [[ 0, 92], [92, 92]]] How do you find the Euclidean distance for each vector in A and B efficiently? I…
user1658296
  • 1,398
  • 2
  • 18
  • 46
6
votes
1 answer

Weighted Euclidean Distance in R

I'd like to create a distance-matrix with weighted euclidean distances from a data frame. The weights will be defined in a vector. Here's an example: library("cluster") a <- c(1,2,3,4,5) b <- c(5,4,3,2,1) c <- c(5,4,1,2,3) df <-…
h7681
  • 355
  • 4
  • 13
6
votes
2 answers

R - How to get row & column subscripts of matched elements from a distance matrix

I have an integer vector vec1 and I am generating a distant matrix using dist function. I want to get the coordinates (row and column) of element of certain value in the distance matrix. Essentially I would like to get the pair of elements that are…
DKangeyan
  • 533
  • 6
  • 14
6
votes
3 answers

How to approximate Euclidean distance on the integer plane, without overflow?

I'm working on a platform that has only integer arithmetic. The application uses geographic information, and I'm representing points by (x, y) coordinates where x and y are distances measured in meters. As an approximation, I want to compute the…
Norman Ramsey
  • 198,648
  • 61
  • 360
  • 533
6
votes
2 answers

Efficiently accessing pairwise distances

I have a distance matrix: > mat hydrogen helium lithium beryllium boron hydrogen 0.000000 2.065564 3.940308 2.647510 2.671674 helium 2.065564 0.000000 2.365661 1.697749 1.319400 lithium 3.940308 2.365661 0.000000 3.188148…
Dex
  • 63
  • 4
6
votes
4 answers

Euclidian Distance Python Implementation

I am playing with the following code from programming collective intelligence, this is a function from the book that calculated eclidian distance between two movie critics. This function sums the difference of the rankings in the dictionary, but…
Hamza Yerlikaya
  • 49,047
  • 44
  • 147
  • 241
6
votes
2 answers

Pycuda Blocks and Grids to work with big datas

I need help to know the size of my blocks and grids. I'm building a python app to perform metric calculations based on scipy as: Euclidean distance, Manhattan, Pearson, Cosine, joined other. The project is PycudaDistances. It seems to work very well…
Vinnicyus Gracindo
  • 162
  • 1
  • 2
  • 6