Class JensenShannonDistance

java.lang.Object
smile.math.distance.JensenShannonDistance
All Implemented Interfaces:
Serializable, ToDoubleBiFunction<double[],double[]>, Distance<double[]>, Metric<double[]>

public class JensenShannonDistance extends Object implements Metric<double[]>
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.

The Jensen-Shannon divergence is a symmetrized and smoothed version of the Kullback-Leibler divergence . It is defined by

     J(P||Q) = (D(P||M) + D(Q||M)) / 2
 
where M = (P+Q)/2 and D(·||·) is KL divergence. Different from the Kullback-Leibler divergence, it is always a finite value.

The square root of the Jensen-Shannon divergence is a metric, which is calculated by this class.

See Also:
  • Constructor Details

    • JensenShannonDistance

      public JensenShannonDistance()
      Constructor.
  • Method Details

    • toString

      public String toString()
      Overrides:
      toString in class Object
    • d

      public double d(double[] x, double[] y)
      Description copied from interface: Distance
      Returns the distance measure between two objects.
      Specified by:
      d in interface Distance<double[]>
      Parameters:
      x - an object.
      y - an object.
      Returns:
      the distance.