001/** 002 * Average.java 003 * jCOLIBRI2 framework. 004 * @author Juan A. Recio-Garc�a. 005 * GAIA - Group for Artificial Intelligence Applications 006 * http://gaia.fdi.ucm.es 007 * 03/01/2007 008 */ 009package es.ucm.fdi.gaia.jcolibri.method.retrieve.NNretrieval.similarity.global; 010 011import es.ucm.fdi.gaia.jcolibri.method.retrieve.NNretrieval.similarity.StandardGlobalSimilarityFunction; 012 013/** 014 * This function computes the average of the similarites of its subattributes. 015 * @author Juan A. Recio-Garcia 016 * @version 1.0 017 */ 018public class Average extends StandardGlobalSimilarityFunction { 019 020 021 public double computeSimilarity(double[] values, double[] weigths, int ivalue) 022 { 023 double acum = 0; 024 double weigthsAcum = 0; 025 for(int i=0; i<ivalue; i++) 026 { 027 acum += values[i] * weigths[i]; 028 weigthsAcum += weigths[i]; 029 } 030 return acum/weigthsAcum; 031 } 032 033 034}