A bunch of distance measures that extend Array.
gem sources -a http://gemcutter.org sudo gem install distance_measures
a = [1,1] b = [2,2] a.euclidean_distance(b) a.cosine_similarity(b) a.jaccard_index(b) a.jaccard_distance(b) a.binary_jaccard_index(b) a.binary_jaccard_distance(b) a.tanimoto_coefficient(b) a.haversine_distance(b)
This may or may not be the complete list, best thing is to check the source code.
There are also a couple bonus methods:
a.dot_product(b) a.sum_of_squares a.intersection_with(b) a.union_with(b) # When your dealing with 1's and 0's a.binary_intersection_with(b) a.binary_union_with(b)
Copyright © 2010 reddavis. See LICENSE for details.