5.6.2.8. statsmodels.sandbox.infotheo.logsumexp

statsmodels.sandbox.infotheo.logsumexp(a, axis=None)[source]

Compute the log of the sum of exponentials log(e^{a_1}+...e^{a_n}) of a

Avoids numerical overflow.

Parameters:

a : array-like

The vector to exponentiate and sum

axis : int, optional

The axis along which to apply the operation. Defaults is None.

Returns:

sum(log(exp(a)))

Notes

This function was taken from the mailing list http://mail.scipy.org/pipermail/scipy-user/2009-October/022931.html

This should be superceded by the ufunc when it is finished.