You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mahout.apache.org by "Ted Dunning (JIRA)" <ji...@apache.org> on 2009/06/08 22:32:07 UTC
[jira] Commented: (MAHOUT-130) Vector should allow for other
normalize powers than the L-2 norm
[ https://issues.apache.org/jira/browse/MAHOUT-130?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12717394#action_12717394 ]
Ted Dunning commented on MAHOUT-130:
------------------------------------
I would recommend externalizing a norm function. It would also be useful for the norm to support L_0 (number of non-zero elements) and L_infty (max element) as specially cases in addition to L_1 and L_2.
Also, there is no need to allocate a vector here:
+ Vector vec = like();
+ for (int i = 0; i< cardinality(); i++){
+ vec.setQuick(i, Math.pow(getQuick(i), power));
+ }
+ val = vec.zSum();
Better to just keep the sum in a local variable:
val = 0;
for (int i = 0; i< cardinality(); i++){
val += Math.pow(getQuick(i), power);
}
val = vec.zSum();
This saves the allocation and improves cache coherence. Accuracy could conceivably be a few ULPS worse if zSum is implemented really well (which it isn't).
> Vector should allow for other normalize powers than the L-2 norm
> ----------------------------------------------------------------
>
> Key: MAHOUT-130
> URL: https://issues.apache.org/jira/browse/MAHOUT-130
> Project: Mahout
> Issue Type: Improvement
> Reporter: Grant Ingersoll
> Assignee: Grant Ingersoll
> Priority: Minor
> Attachments: MAHOUT-130.patch
>
>
> Modify Vector to allow other normalize functions for the Vector
> See http://www.lucidimagination.com/search/document/bf3a7a7a004d4191/norm_calculations
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.