Bhattacharyya distance between two normalized histograms.

@param histogram1 Normalized histogram.
@param histogram2 Normalized histogram.
@return The Bhattacharyya distance between the two histograms.
184895
public static double Bhattacharyya(double[] histogram1, double[] histogram2) {
        int bins = histogram1.length; // histogram bins
        double b = 0; // Bhattacharyya's coefficient

        for (int i = 0; i < bins; i++)
            b += Math.sqrt(histogram1[i]) * Math.sqrt(histogram2[i]);

        // Bhattacharyya distance between the two distributions
        return Math.sqrt(1.0 - b);
    }
1131586
public static boolean isLessOrEqual(BigDecimal bigNum1, BigDecimal bigNum2) {
		Assert.notNull(bigNum1);
		Assert.notNull(bigNum2);
		return bigNum1.compareTo(bigNum2) <= 0;
	}
463058
def hue_similarity( color1, color2 )
      deg1   = color1.to_hsl.h
      deg2   = color2.to_hsl.h
      deg1  += 1 if deg1 < 0
      deg2  += 1 if deg2 < 0
      delta  = (deg1 - deg2).abs
      delta  = 1 - delta if delta > 0.5
      delta * 360
    end
1112107
public static double getDistance(double x1, double y1, double x2, double y2)
    {
        final double x = x2 - x1;
        final double y = y2 - y1;

        return StrictMath.sqrt(x * x + y * y);
    }
1222033
public static boolean isGreaterOrEqual(BigDecimal bigNum1, BigDecimal bigNum2) {
		Assert.notNull(bigNum1);
		Assert.notNull(bigNum2);
		return bigNum1.compareTo(bigNum2) >= 0;
	}
1294338
def __hammingDistance(s1, s2):
        '''
        
        '''

        l1 = len(s1)
        l2 = len(s2)

        if l1 != l2:
            raise ValueError("Hamming distance requires strings of same size.")

        return sum(ch1 != ch2 for ch1, ch2 in zip(s1, s2))
815600
def rgb_distance(rgb1, rgb2):
    '''
    
    '''
    return sum(map(lambda c: (c[0] - c[1]) ** 2,
        zip(rgb1, rgb2)))
597127
def distance(vec1, vec2):
        """"""
        if isinstance(vec1, Vector2) \
                and isinstance(vec2, Vector2):
            dist_vec = vec2 - vec1
            return dist_vec.length()
        else:
            raise TypeError("vec1 and vec2 must be Vector2's")
72964
public double normalizedDistance(double[] point1, double[] point2) throws Exception {
    return Math.sqrt(distance2(point1, point2)) / point1.length;
  }
379142
private double[] max(double[] distances1, double[] distances2) {
    if(distances1.length != distances2.length) {
      throw new RuntimeException("different lengths!");
    }

    double[] result = new double[distances1.length];
    for(int i = 0; i < distances1.length; i++) {
      result[i] = Math.max(distances1[i], distances2[i]);
    }
    return result;
  }
1258553
public static int compareTo(byte[] b1, int s1, int l1, byte[] b2, int s2,
      int l2) {
    return LexicographicalComparerHolder.BEST_COMPARER.compareTo(
        b1, s1, l1, b2, s2, l2);
  }
224597
public static final double distance(final Point2D a, final Point2D b)
    {
        return Point2DJSO.distance(a.getJSO(), b.getJSO());
    }
1136801
public long distance2(int[] point1, int[] point2) throws Exception {
    if (point1.length == point2.length) {
      long sum = 0;
      for (int i = 0; i < point1.length; i++) {
        sum = sum + (point2[i] - point1[i]) * (point2[i] - point1[i]);
      }
      return sum;
    }
    else {
      throw new Exception("Exception in Euclidean distance: array lengths are not equal");
    }
  }
480595
public void setColorRange(int firstIndex, int lastIndex, int color1, int color2) {
		for (int i = firstIndex; i <= lastIndex; i++)
			map[i] = ImageMath.mixColors((float)(i-firstIndex)/(lastIndex-firstIndex), color1, color2);
	}
706426
public static int getDistance (@Nullable final char [] aStr1, @Nullable final char [] aStr2)
  {
    final int nLen1 = aStr1 == null ? 0 : aStr1.length;
    final int nLen2 = aStr2 == null ? 0 : aStr2.length;

    if (nLen1 == 0)
      return nLen2;
    if (nLen2 == 0)
      return nLen1;

    return _getDistance111 (aStr1, nLen1, aStr2, nLen2);
  }
1190681
public static double getRobustTreeEditDistance(String dom1, String dom2) {

		LblTree domTree1 = null, domTree2 = null;
		try {
			domTree1 = getDomTree(dom1);
			domTree2 = getDomTree(dom2);
		} catch (IOException e) {
			e.printStackTrace();
		}

		double DD = 0.0;
		RTED_InfoTree_Opt rted;
		double ted;

		rted = new RTED_InfoTree_Opt(1, 1, 1);

		// compute tree edit distance
		rted.init(domTree1, domTree2);

		int maxSize = Math.max(domTree1.getNodeCount(), domTree2.getNodeCount());

		rted.computeOptimalStrategy();
		ted = rted.nonNormalizedTreeDist();
		ted /= (double) maxSize;

		DD = ted;
		return DD;
	}
835402
@SafeVarargs
    public static Map<String, Double> histogramsPlus(Map<String, Double>... histograms) {
        switch (histograms.length) {
            case 0:
                throw new IllegalArgumentException("histograms.length=" + histograms.length + "; needs to be >= 2");
                // return null;
            case 1:
                return histograms[0];
            default: // standard
        }


        final Set<String> mergedKeys = new HashSet<>();
        for (Map<String, Double> histogram : histograms) {
            mergedKeys.addAll(histogram.keySet());
        }
        final HashMap<String, Double> mergedHistogram = new HashMap<>();

        for (String key : mergedKeys) {
            double value = 0.0;
            for (Map<String, Double> histogram : histograms) {
                value += histogram.getOrDefault(key, 0.0);
            }
            mergedHistogram.put(key, value);
        }

        return mergedHistogram;
    }