Here you can find the source of normalizeProb(double[] prob)
public static double normalizeProb(double[] prob)
//package com.java2s; //License from project: Apache License public class Main { /**/*from w w w .j av a2 s . co m*/ * normalize probabilities and check convergence by the maximum probability * @return maximum of probabilities */ public static double normalizeProb(double[] prob) { double maxp = 0, sump = 0; for (int i = 0; i < prob.length; ++i) sump += prob[i]; for (int i = 0; i < prob.length; ++i) { double p = prob[i] / sump; if (maxp < p) maxp = p; prob[i] = p; } return maxp; } }