code: public static double JensenShannonDivergence(double[] x, double[] y) {
          double[] m = new double[x.length];
          for (int i = 0; i < m.length; i++) {
              m[i] = (x[i] + y[i]) / 2;
          }
  
          return (KullbackLeiblerDivergence(x, m) + KullbackLeiblerDivergence(y, m)) / 2;
      }
docs: Jensen-Shannon divergence JS(P||Q) = (KL(P||M) + KL(Q||M)) / 2, where
  M = (P+Q)/2. The Jensen-Shannon divergence is a popular
  method of measuring the similarity between two probability distributions.
  It is also known as information radius or total divergence to the average.
  It is based on the Kullback-Leibler divergence, with the difference that
  it is always a finite value. The square root of the Jensen-Shannon divergence
  is a metric.