def jaccard_index(u, v)
      intersection = u & v
      union = u | v
      intersection.length.to_f / union.length
    end
def jaccard_index(u, v)
      intersection = u & v
      union = u | v
      intersection.length.to_f / union.length
    end
call-seq:
     jaccard_index(u, v) -> Float

 Give the similarity between two binary vectors +u+ and +v+. Calculated as:
  jaccard_index = |intersection| / |union|

 In which intersection and union refer to +u+ and +v+ and |x| is the
 cardinality of set x.

 For example:
   jaccard_index([1, 0], [1]) == 0.5

 Because |intersection| = |(1)| = 1 and |union| = |(0, 1)| = 2.

 See: http://en.wikipedia.org/wiki/Jaccard_coefficient

 Arguments:
 - +u+ -> Array.
 - +v+ -> Array.
 Returns:
 - Float value representing the Jaccard similarity coefficient between
   +u+ and +v+.