protected double logOfSum(double logOfX,double logOfY){
  if (Double.isNaN(logOfX)) {
    return logOfY;
  }
  if (Double.isNaN(logOfY)) {
    return logOfX;
  }
  if (logOfX > logOfY) {
    return logOfX + Math.log(1 + Math.exp(logOfY - logOfX));
  }
 else {
    return logOfY + Math.log(1 + Math.exp(logOfX - logOfY));
  }
}

protected double logOfSum ( double logOfX , double logOfY ) { if ( Double . isNaN ( logOfX ) ) { return logOfY ; } if ( Double . isNaN ( logOfY ) ) { return logOfX ; } if ( logOfX > logOfY ) { return logOfX + Math . log ( 1 + Math . exp ( logOfY - logOfX ) ) ; } else { return logOfY + Math . log ( 1 + Math . exp ( logOfX - logOfY ) ) ; } }
computes the logarithm of x and y given the logarithms of x and y . this is based on tobias p . mann ' s description in " numerically stable hidden markov implementation " ( 2006 ) .
