Hi, in Moses, probabilities only get multiplied, not subtracted. So, if they need to be added/subtracted you need to convert back to non-log numbers.
You code seems to be doing the right thing. -phi 2009/3/26 Felipe Sánchez Martínez <[email protected]>: > 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 > _______________________________________________ Moses-support mailing list [email protected] http://mailman.mit.edu/mailman/listinfo/moses-support
