-
-
Notifications
You must be signed in to change notification settings - Fork 11.1k
Open
Description
scipy has the logsumexp function which avoids unnecessary calls to log
and thus probably saves a couple ulp of rounding errors.
The underflow avoidance should already be present in numpys current version.
I don't see a reason why we couldn't do this directly in logaddexp.reduce. The only possible issue is that the reduce loop is blocked to a few thousand elements by nditer so the maximum in the kernel is no global maximum. But I don't think that makes a big difference in numeric terms as only the largest terms even contribute to the sum.
But I would appreciate input of an expert in this regard.
A prototype implementation is available here:
https://github.com/juliantaylor/numpy/tree/logaddexp