Here you can find the source of meanAbsolute(List
Parameter | Description |
---|---|
vector | Vector whose elements are to be averaged |
public static float meanAbsolute(List<Float> vector)
//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(); } }