Here you can find the source of averageLog(List
public static double averageLog(List<Double> logList)
//package com.java2s; //License from project: GNU General Public License import java.util.List; public class Main { public static double averageLog(double[] logs) { double max = max(logs); double norm = 0.0; for (int i = 0; i < logs.length; i++) { norm += Math.exp(logs[i] - max); }//from w w w . ja va2 s . c om norm = Math.log(norm) + max; return norm - Math.log(logs.length); } public static double averageLog(List<Double> logList) { if (logList.size() == 1) return logList.get(0); double[] logs = new double[logList.size()]; for (int i = 0; i < logs.length; i++) { logs[i] = logList.get(i); } return averageLog(logs); } private static double max(double[] a) { double m = a[0]; for (int i = 1; i < a.length; i++) { if (a[i] > m) { m = a[i]; } } return m; } private static void exp(double[] a) { for (int i = 0; i < a.length; i++) { a[i] = Math.exp(a[i]); } } }