-
-
Notifications
You must be signed in to change notification settings - Fork 5.1k
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
logsumexp with sign indicator - enable calculation with negative signs #4627
Comments
The b array almost allows you to do this: you can just put your sign indicators in there. The only thing lacking is that the result will be NaN if the answer comes out negative; so a simple implementation could just detect that, flip the sign on all the b values, and rerun the function. You'd still want a wrapper that returned sign information. |
Ok, that would be great. Would an implementetion detecting NaN results and flipping signs be faster than mine? Also, yes, you'd want a wrapper returning sign information and you'd want this use of the |
Has been fixed by gh-4859, so closing. |
Wonderful to see this effect. Next time I'll not be bound to PhD work, so I might help beyond filing issues. Thanks to Anne! |
This is a repost of numpy/numpy#5652 to where a logsumexp request actually belongs.
So my problem has been the following: I had to calculate the logsumexp of some numbers in logspace for accuracy reasons, but some of the elements of the array have negative sign. I implemented the following code, which you might want to integrate into the upstream logsumexp implementation of numpy.
The
sign
argument is a matrix assumed to be filled with +1 or -1 depending on the sign of the number before the log transformation.I'm not sure I passed on the
b
parameter correctly (I never made use of it before). Here is a test method:The text was updated successfully, but these errors were encountered: