@@ -0,0 +1,2671 @@
+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 */%0Aimport de.lmu.ifi.dbs.elki.data.NumberVector;%0Aimport de.lmu.ifi.dbs.elki.utilities.documentation.Reference;%0Aimport de.lmu.ifi.dbs.elki.utilities.optionhandling.AbstractParameterizer;%0A%0A/**%0A * Canberra distance function, a variation of Manhattan distance.%0A * %0A * %3Cp%3E%0A * Reference:%3Cbr /%3E%0A * G. N. Lance, W. T. Williams%3Cbr /%3E%0A * Computer programs for hierarchical polythetic classification (%22similarity%0A * analysis%22)%3Cbr /%3E%0A * In: Computer Journal, Volume 9, Issue 1%0A * %3C/p%3E%0A * %0A * @author Erich Schubert%0A */%0A@Reference(authors = %22G. N. Lance, W. T. Williams%22, title = %22Computer programs for hierarchical polythetic classification (similarity analysis).%22, booktitle = %22Computer Journal, Volume 9, Issue 1%22, url = %22http://comjnl.oxfordjournals.org/content/9/1/60.short%22)%0Apublic class CanberraDistanceFunction extends AbstractVectorDoubleDistanceFunction %7B%0A  /**%0A   * Static instance. Use this!%0A   */%0A  public static final CanberraDistanceFunction STATIC = new CanberraDistanceFunction();%0A%0A  /**%0A   * Constructor.%0A   */%0A  protected CanberraDistanceFunction() %7B%0A    super();%0A  %7D%0A%0A  @Override%0A  public double doubleDistance(NumberVector%3C?, ?%3E o1, NumberVector%3C?, ?%3E o2) %7B%0A    final int dim = o1.getDimensionality();%0A    double sum = 0.0;%0A    for(int i = 1; i %3C= dim; i++) %7B%0A      double v1 = o1.doubleValue(i);%0A      double v2 = o2.doubleValue(i);%0A      sum += Math.abs(v1 - v2) / (Math.abs(v1) + Math.abs(v2));%0A    %7D%0A    return sum;%0A  %7D%0A%0A  /**%0A   * Parameterization class.%0A   * %0A   * @author Erich Schubert%0A   * %0A   * @apiviz.exclude%0A   */%0A  public static class Parameterizer extends AbstractParameterizer %7B%0A    @Override%0A    protected CanberraDistanceFunction makeInstance() %7B%0A      return CanberraDistanceFunction.STATIC;%0A    %7D%0A  %7D%0A%7D

Add Canberra distance.