-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Stats.sum
doesn't handle NaNs, infinities and overflow correctly
#11059
Comments
I think I will take this issue. |
`[1e20, 1.0, -1e20].sum()` returns `0.0`. This happens because during the summation, `1.0` is too small relative to `1e20`, making it negligible. I have tried Kahan summation but it hasn't fixed the problem. Therefore, I've used Python's `fsum()` implementation with some help from Jason Fager and Huon Wilson. For more details, read: www.cs.cmu.edu/~quake-papers/robust-arithmetic.ps Moreover, benchmark and unit tests were added. Note: `Status.sum` is still not fully fixed. It doesn't handle NaNs, infinities and overflow correctly. See issue 11059: rust-lang#11059
@huonw , |
@g3xzh I don't see any reason to depart from the algorithm that Python is using: http://bugs.python.org/file10357/msum4.py |
@huonw - 10x. I hope I will finish working on it this week. |
@g3xzh any progress? :) |
@huonw there was some. However, I cannot compile it (rustc is broken on my machine) and because of the exam season I could not continue working on it. :-\ |
If someone else is interested, is it ok if they work on it? |
I don't mind. My last exam, this semester, is in the 13rd, though. :) |
This is now in tests, not in extra. |
Triage: as the #29553 is related, in the sense that it might make this crate stable, or at least parts of it. |
This seems to be "fixed" because it's no longer available to code that might feed NaNs, infinity or overflowing values to it. |
Closing, due to the last two comments. |
Like @huonw has put it here:
Stats.sum
doesn't handle "extreme" values nicely.The text was updated successfully, but these errors were encountered: