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     */
009    package jcolibri.method.retrieve.NNretrieval.similarity.global;
010    
011    import jcolibri.method.retrieve.NNretrieval.similarity.StandardGlobalSimilarityFunction;
012    
013    
014    /**
015     * This function computes the average of the similarites of its subattributes.
016     * @author Juan A. Recio-Garcia
017     * @version 1.0
018     */
019    public class Average extends StandardGlobalSimilarityFunction {
020    
021    
022            public double computeSimilarity(double[] values, double[] weigths, int ivalue)
023            {
024                    double acum = 0;
025                    double weigthsAcum = 0;
026                    for(int i=0; i<ivalue; i++)
027                    {
028                            acum += values[i] * weigths[i];
029                            weigthsAcum += weigths[i];
030                    }
031                    return acum/weigthsAcum;
032            }
033    
034    
035    }