Hi all,

Perhaps this is not the proper place to make this question but I do not
know where to ask. Sorry for the inconvenience.

Computation of probabilities is usually done by using the log of the
probabilities instead of the probabilities directly. To add to log
probabilities I use the following function:

double log_add (double x, double y) {
  if (x < y) {
    double temp;
    temp = x; 
    x = y; 
    y = temp;
  }
                    
  if (y == -numeric_limits<double>::infinity()) {  //log(0) = - Infinity
    cerr<<"log_add: one of the log probs is null"<<endl;
    return x;
  } else {
    double diff = y - x;
    return x + log(1.0 + exp(diff));
  }
}

How do you do when the probabilities need to be subtracted? Do you just
convert them to normal probabilities, subtract the probabilities, and
then go back to log probabilities?

Thanks in advance.

-- 
Felipe

_______________________________________________
Moses-support mailing list
[email protected]
http://mailman.mit.edu/mailman/listinfo/moses-support

Reply via email to