On Nov 4, 2011, at 10:58 AM, WangRamon wrote:

> 
> 
> 
> 
> Hi All  I'm reading the code of SquaredEuclideanDistanceMeasure, the 
> "distance(double centroidLengthSquare, Vector centroid, Vector v)" method 
> confused me a lot, i don't know why we choose this expression 
> "centroidLengthSquare - 2 * v.dot(centroid) + v.getLengthSquared()" to 
> calculate the distance?

Math is as Sebastian said, the purpose is that it can save some steps in the 
computation, for instance, see the KMeans implementation where you are often 
calculating the distance between some point and a centroid.  We have the 
centroidLengthSquare handy, so it saves a fair amount of work.


> What is the best case to use this Measure? BTW,  I think it would be great if 
> we can have a wiki or some detail user guide or more comments in the source 
> code to explain each distance measure implementation, that will really help, 
> thanks guys.

That would be a great addition!  Also, javadoc would be helpful, so patches 
would be great there.

--------------------------------------------
Grant Ingersoll
http://www.lucidimagination.com



Reply via email to