You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Benjamin McCann (JIRA)" <ji...@apache.org> on 2011/03/11 07:34:00 UTC
[jira] Commented: (MATH-545) Feature Request: RealVector cosine
[ https://issues.apache.org/jira/browse/MATH-545?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13005517#comment-13005517 ]
Benjamin McCann commented on MATH-545:
--------------------------------------
I guess it's pretty simple, but it still might be nice as a convenience method:
public double cosine(double[] a1, double[] a2) {
ArrayRealVector v1 = new ArrayRealVector(a1);
ArrayRealVector v2 = new ArrayRealVector(a2);
return v1.dotProduct(v2) / (v1.getNorm() * v2.getNorm());
}
> Feature Request: RealVector cosine
> ----------------------------------
>
> Key: MATH-545
> URL: https://issues.apache.org/jira/browse/MATH-545
> Project: Commons Math
> Issue Type: New Feature
> Reporter: Benjamin McCann
>
> I'd like a method to compute the cosine similarity between vectors.
> http://en.wikipedia.org/wiki/Cosine_similarity
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira