Skip to content
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

Closed
wants to merge 4 commits into from
Closed

Kahan summation #1829

wants to merge 4 commits into from

Conversation

stefanv
Copy link
Member

@stefanv stefanv commented Dec 15, 2015

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.

np.sum(z, axis=1))
assert_array_almost_equal(kahan_sum(z, axis=0),
np.sum(z, axis=0))

Copy link
Member

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.

@emmanuelle
Copy link
Member

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.
"""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Returns section please

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants