On Thu, May 28, 2009 at 10:56 PM, Shashikant Kore <[email protected]>wrote:
> I tried L1 and L2 norms. The centroid definitely looks better, but the
> values are still close to zero.
>
How close is that? 1e-3? (that I would expect) or 1e-300? (that would be
wrong)
> Please let me know if my understanding of L1, L2 norms is correct as
> shown with the code below.
>
You understood what I said, but I said the wrong thing. See my (oops)
posting a few messages back.
// L1 Norm ... centroid is difficult to calculate in a few lines of code
// what you had for the L1 norm is actually the centroid computation for
the L2 norm
public Vector computeCentroid() {
Vector result = new SparseVector(pointTotal.cardinality());
double sum = pointTotal.zSum();
for (int i = 0; i < pointTotal.cardinality(); i++)
result.set(i, pointTotal.get(i) / sum); // Dividing each coordinate
value by the
sum of all weights
return result;
}