mixLogSum
Compute the mixture log sum
Contents
Syntax
- output=mixLogSum(input)
Description
mixLogSum(input) returns log(e^x + e^y + e^z...) when input=[x, y,z..].
This function is more robust, For instance, compare the difference:
- mixLogSum([-2000, -1999])
- log(sum(exp([-2000, -1999])))
This function is primarily used for computing the log likelihood of a GMM. For efficiency, you can use the equivalent mixLogSumMex.mex* instead.
Example
fprintf('mixLogSum([-2000, -1999])=%f\n', mixLogSum([-2000, -1999])); fprintf('log(sum(exp([-2000, -1999])))=%f\n', log(sum(exp([-2000, -1999]))));
mixLogSum([-2000, -1999])=-1998.686738 log(sum(exp([-2000, -1999])))=-Inf