@@ -0,0 +1,2968 @@
+package de.lmu.ifi.dbs.elki.distance.distancefunction;%0A%0A/*%0A This file is part of ELKI:%0A Environment for Developing KDD-Applications Supported by Index-Structures%0A%0A Copyright (C) 2011%0A Ludwig-Maximilians-Universit%C3%A4t M%C3%BCnchen%0A Lehr- und Forschungseinheit f%C3%BCr Datenbanksysteme%0A ELKI Development Team%0A%0A This program is free software: you can redistribute it and/or modify%0A it under the terms of the GNU Affero General Public License as published by%0A the Free Software Foundation, either version 3 of the License, or%0A (at your option) any later version.%0A%0A This program is distributed in the hope that it will be useful,%0A but WITHOUT ANY WARRANTY; without even the implied warranty of%0A MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the%0A GNU Affero General Public License for more details.%0A%0A You should have received a copy of the GNU Affero General Public License%0A along with this program.  If not, see %3Chttp://www.gnu.org/licenses/%3E.%0A */%0A%0Aimport de.lmu.ifi.dbs.elki.data.NumberVector;%0Aimport de.lmu.ifi.dbs.elki.utilities.optionhandling.AbstractParameterizer;%0A%0A/**%0A * Provides the Jeffrey Divergence Distance for FeatureVectors.%0A * %0A * @author Erich Schubert%0A */%0Apublic class JeffreyDivergenceDistanceFunction extends AbstractVectorDoubleDistanceFunction %7B%0A  /**%0A   * Static instance. Use this!%0A   */%0A  public static final JeffreyDivergenceDistanceFunction STATIC = new JeffreyDivergenceDistanceFunction();%0A%0A  /**%0A   * Constructor for the Jeffrey divergence.%0A   * %0A   * @deprecated Use static instance!%0A   */%0A  @Deprecated%0A  public JeffreyDivergenceDistanceFunction() %7B%0A  %7D%0A%0A  @Override%0A  public double doubleDistance(NumberVector%3C?, ?%3E v1, NumberVector%3C?, ?%3E v2) %7B%0A    final int dim1 = v1.getDimensionality();%0A    if(dim1 != v2.getDimensionality()) %7B%0A      throw new IllegalArgumentException(%22Different dimensionality of FeatureVectors%22 + %22%5Cn  first argument: %22 + v1.toString() + %22%5Cn  second argument: %22 + v2.toString() + %22%5Cn%22 + v1.getDimensionality() + %22!=%22 + v2.getDimensionality());%0A    %7D%0A    double dist = 0;%0A    for(int i = 1; i %3C= dim1; i++) %7B%0A      final double xi = v1.doubleValue(i);%0A      final double yi = v2.doubleValue(i);%0A      final double mi = (xi + yi) / 2;%0A      dist += xi * Math.log(xi / mi);%0A      dist += yi * Math.log(yi / mi);%0A    %7D%0A    return dist;%0A  %7D%0A%0A  @Override%0A  public String toString() %7B%0A    return %22JeffreyDivergenceDistance%22;%0A  %7D%0A%0A  @Override%0A  public boolean equals(Object obj) %7B%0A    if(obj == null) %7B%0A      return false;%0A    %7D%0A    if(obj == this) %7B%0A      return true;%0A    %7D%0A    if(this.getClass().equals(obj.getClass())) %7B%0A      return true;%0A    %7D%0A    return super.equals(obj);%0A  %7D%0A%0A  /**%0A   * Parameterization class, using the static instance.%0A   * %0A   * @author Erich Schubert%0A   * %0A   * @apiviz.exclude%0A   */%0A  public static class Parameterizer extends AbstractParameterizer %7B%0A    @Override%0A    protected JeffreyDivergenceDistanceFunction makeInstance() %7B%0A      return JeffreyDivergenceDistanceFunction.STATIC;%0A    %7D%0A  %7D%0A%7D

Add Jeffrey Divergence. Slightly different implementation than suggested by Johannes.