private static double hammingSimilarity(List<double[]> featuresCac1,
                                            List<double[]> featuresCac2) {
        int diff = 0;
        int sumAll = 0;

        if (featuresCac1.size() != featuresCac2.size())
            return -1;

        for (int i = 0; i < featuresCac1.size(); ++i) {
            sumAll += featuresCac1.get(i).length;
            double[] ds1 = featuresCac1.get(i);
            double[] ds2 = featuresCac2.get(i);

            if (ds1.length != ds2.length)
                return -1;

            for (int j = 0; j < ds1.length; ++j) {
                diff += doubleEquals(ds1[j], ds2[j]) ? 0 : 1;
            }
        }
        return diff / (double) sumAll;
    }