-
Notifications
You must be signed in to change notification settings - Fork 53
PR: Add logaddexp to the spec #124
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Thanks @steff456
The specification looks good, but I'm not sure about this name change. If all libraries name it |
MATLAB uses logsumexp, but it operates on a vector (see https://nhigham.com/2021/01/05/what-is-the-log-sum-exp-function/), and it's also the "mathematical" name (https://en.wikipedia.org/wiki/LogSumExp). Presumably the fact that it operates on two arguments is why it was changed to logaddexp. Is reduction part of the spec? I am surprised that logaddexp is defined as a two argument function rather than a function on a vector, but I suppose that's because you can just use |
Reductions as in
You're talking about a different function altogether. From your first link: "The log-sum-exp function takes as input a real n-vector x and returns the scalar" From the
It's not a reduction, as
|
|
I think you missed the point of what I said. logaddexp is associative. Its reduction (via >>> np.logaddexp.reduce(np.arange(5, dtype=np.float64))
4.451914395937593 Most references talk about the n-argument version (logsumexp), so I'm surprised that NumPy only has a two argument version, but I imagine that the reason is that you can easily get the n-argument version via |
Hi guys, You are right! I didn't realize that |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Will add two minor edits, but otherwise looks good! Thanks @steff456!
As this PR has been open a week, the proposal straightforward, and can be readily implemented based on existing standardized APIs, will merge. |
This PR
logaddexp
, which calculates the logarithm of the sum of exponentiations of the inputs.