finding euclidean distance,better code?

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Fri Mar 28 11:54:56 EDT 2008


En Fri, 28 Mar 2008 12:15:48 -0300, harryos <oswald.harry at gmail.com>  
escribió:

>> The code is pretty legible as it is now. Anyway, using min() and a
>> generator:
>>
>>
>
> hi
> is this calculated distance really Euclidean distance? When i checked
> wikipedia http://en.wikipedia.org/wiki/Euclidean_distance
> it shows a calculation involving sum of squares of the differences of
> elements.Here in this code ,the sum of coordinates are used? is that a
> different measure?

(Thanks for trimming the irrelevant parts of the message, that's good; but  
you trimmed too much text, even attribution lines - the above quoted  
sentence was mine)

That's what I said in another paragraph. "sum of coordinates" is using a  
different distance definition; it's the way you measure distance in a city  
with square blocks. I don't know if the distance itself has a name, but  
the norm from which it is derived is called norm-1, or L1; the usual  
euclidean distance is derived from norm-2.
See http://mathworld.wolfram.com/VectorNorm.html

If you only want to see if two things are "close enough", this provides a  
faster measure than the euclidean distance.

-- 
Gabriel Genellina




More information about the Python-list mailing list