Here you can find the source of normalizeLog(double[] logs)
public static void normalizeLog(double[] logs)
//package com.java2s; //License from project: GNU General Public License public class Main { public static void normalizeLog(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. j av a 2 s . co m norm = Math.log(norm) + max; add(logs, -norm); exp(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]); } } public static void add(double[][][] a, double v) { for (int i = 0; i < a.length; i++) { add(a[i], v); } } public static void add(double[][] a, double v) { for (int i = 0; i < a.length; i++) { add(a[i], v); } } public static void add(double[] a, double v) { for (int i = 0; i < a.length; i++) { a[i] += v; } } public static void add(double[] target, double[] source) { if (target.length != source.length) { throw new IllegalArgumentException( "Support sizes not equal: " + target.length + " != " + source.length); } for (int i = 0; i < target.length; i++) { target[i] += source[i]; } } }