public static double[] lnToNormaliedProb(final double[] logs){
  final double[] prob=new double[logs.length];
  double max=logs[0];
  for (int i=1; i < logs.length; i++) {
    if (max < logs[i]) {
      max=logs[i];
    }
  }
  double sum=0.0;
  for (int i=0; i < logs.length; i++) {
    final double v=Math.exp(logs[i] - max);
    prob[i]=v;
    sum+=v;
  }
  for (int i=0; i < logs.length; i++) {
    prob[i]=prob[i] / sum;
  }
  return prob;
}

public static double [ ] lnToNormaliedProb ( final double [ ] logs ) { final double [ ] prob = new double [ logs . length ] ; double max = logs [ 0 ] ; for ( int i = 1 ; i < logs . length ; i ++ ) { if ( max < logs [ i ] ) { max = logs [ i ] ; } } double sum = 0.0 ; for ( int i = 0 ; i < logs . length ; i ++ ) { final double v = Math . exp ( logs [ i ] - max ) ; prob [ i ] = v ; sum += v ; } for ( int i = 0 ; i < logs . length ; i ++ ) { prob [ i ] = prob [ i ] / sum ; } return prob ; }
normalize an array of ln values to probabilities .
