-
-
Notifications
You must be signed in to change notification settings - Fork 2.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
Kahan summation #1829
Kahan summation #1829
Conversation
np.sum(z, axis=1)) | ||
assert_array_almost_equal(kahan_sum(z, axis=0), | ||
np.sum(z, axis=0)) | ||
|
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.
is it possible to add a test where kahan summation would result in a better precision than np.sum
? I tried with the sum of np.arange(n)
since the result is known analytically, but the result was exact for np.sum
.
Hey @stefanv it looks like a neat pull request. To be sure that this feature is needed, could you just give an example where the extra accuracy of Kahan summation is needed to get a correct result? (That's my compulsive habit of trying to keep a codebase as small as possible :-)). |
Input array. | ||
axis : int | ||
Axis along which to sum. | ||
""" |
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.
Returns section please
Implement Kahan summation to improve the accuracy of summed area tables at some computational cost (see #1712). Note that NumPy already uses paired summation, so the improvement is not that big.
An even better algorithm would perhaps be the one by Shewchuk, but that will take more time to figure out.
See also:
If we can, we should look at implementing one of the above.