Here you can find the source of sumLog(double[] logs)
public static double sumLog(double[] logs)
//package com.java2s; //License from project: GNU General Public License public class Main { public static double sumLog(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 www .j ava 2 s . c om norm = Math.log(norm) + max; return norm; } 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]); } } }