Java List Mean meanAbsolute(List vector)

Here you can find the source of meanAbsolute(List vector)

Description

Arithmetic Mean of absolute values of Vector Elements, e.g.

License

Open Source License

Parameter

Parameter Description
vector Vector whose elements are to be averaged

Return

Mean

Declaration

public static float meanAbsolute(List<Float> vector) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * This file is part of Tmetrics./*  w w w  . java 2 s .  c o m*/
 *
 * Tmetrics is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Tmetrics is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Tmetrics. If not, see <http://www.gnu.org/licenses/>.
 *******************************************************************************/

import java.util.List;

public class Main {
    /**
     * Arithmetic Mean of absolute values of Vector Elements, e.g. for mean
     * absolute error computation
     * 
     * @param vector
     *            Vector whose elements are to be averaged
     * @return Mean
     */
    public static float meanAbsolute(List<Float> vector) {
        Float sum = (float) 0;
        for (Float element : vector) {
            // sum += (element);
            sum += Math.abs(element);
        }
        return sum / vector.size();
    }
}

Related

  1. mean(List vals)
  2. mean(List values)
  3. mean(List values)
  4. mean(List values)
  5. mean(List numbers)
  6. meanDouble(List list)
  7. meanDoubleList(List list)
  8. normalizeFromMeanAndStdev(List values, double mean, double stdev)
  9. standardDeviation(List values, Double mean)