code: public static double jaccardIndex(IntegerVector a, IntegerVector b) {
          Set<Integer> intersection = new HashSet<Integer>();
          Set<Integer> union = new HashSet<Integer>();
          for (int i = 0; i < a.length(); ++i) {
              int d = a.get(i);
              intersection.add(d);
              union.add(d);
          }
          Set<Integer> tmp = new HashSet<Integer>();
          for (int i = 0; i < b.length(); ++i) {
              int d = b.get(i);
              tmp.add(d);
              union.add(d);
          }
  
          intersection.retainAll(tmp);
          return ((double)(intersection.size())) / union.size();
      }
docs: Computes the <a href="http://en.wikipedia.org/wiki/Jaccard_index">Jaccard
  index</a> comparing the similarity both {@code IntegerVector}s when viewed
  as sets of samples.