Module: Measurable::Maxmin
 Included in:
 Measurable
 Defined in:
 lib/measurable/maxmin.rb
Instance Method Summary collapse

#maxmin(u, v) ⇒ Object
callseq: maxmin(u, v) > Float.
Instance Method Details
#maxmin(u, v) ⇒ Object
callseq:
maxmin(u, v) > Float
The “Maxmin distance” is used to measure similarity between two vectors.
When used in kmeans clustering, this similarity measure can give better results in some datasets, as pointed out in the paper “Kmeans clustering using Maxmin distance measure” — Visalakshi, N. K.; Suguna, J.
See: ieeexplore.ieee.org/stamp/stamp.jsp?arnumber=05156398
Arguments:

u
> An array of Numeric objects. 
v
> An array of Numeric objects.
Returns:

Similarity between
u
andv
.
Raises:

ArgumentError
> The sizes ofu
andv
don't match.
22 23 24 25 26 27 28 29 30 31 32 33 
# File 'lib/measurable/maxmin.rb', line 22 def maxmin(u, v) # TODO: Change this to a more specific, custommade exception. raise ArgumentError if u.size != v.size sum_min, sum_max = u.zip(v).reduce([0.0, 0.0]) do acc, attributes acc[0] += attributes.min acc[1] += attributes.max acc end sum_min / sum_max end 