LogSumExp¶
- LogSumExp(*args)¶
Logarithm of a sum of exponentials.
Returns the value
, computed without overflow or underflow.
- Available usages:
LogSumExp(logA, logB)
LogSumExp(logValues)
- Parameters:
- logAfloat
First logarithm.
- logBfloat
Second logarithm.
- logValuessequence of float
Logarithms to sum.
- Returns:
- resultfloat
Logarithm of the sum of the exponentials. It is equal to
when the collection is empty or when every term is
, and to
as soon as one term is
. NaN is propagated.
Notes
The implementation uses
. It handles infinities and propagates NaN.
Examples
>>> import math >>> import openturns as ot >>> print('%.6f' % ot.SpecFunc.LogSumExp(math.log(2.0), math.log(3.0))) 1.609438 >>> print('%.6f' % ot.SpecFunc.LogSumExp([math.log(2.0), math.log(3.0), -math.inf])) 1.609438
OpenTURNS