Skip to content

DOC: Mention and try to explain pairwise summation in sum #13737

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

Merged
merged 3 commits into from
Jun 11, 2019

Conversation

seberg
Copy link
Member

@seberg seberg commented Jun 7, 2019

Note that this behavour is of course inherited into np.add.reduce and
many other reductions such as mean or users of this reduction, such
as cov. This is ignored here.

Closes gh-11331, gh-9393, gh-13734


To be honest, not sure I am too happy with it, but it is one of those things that comes up every couple of months.

Note that this behavour is of course inherited into `np.add.reduce` and
many other reductions such as `mean` or users of this reduction, such
as `cov`. This is ignored here.

Closes numpygh-11331, numpygh-9393, numpygh-13734
@takluyver
Copy link
Contributor

Thanks! There's a good chance I wouldn't have opened #13734 if I had found this explanation on the page for the sum() function.

is only used when the summation is along the fast axis in memory.
Note that the exact precision may vary depending on other parameters.
In contrast to NumPy, Python's ``math.fsum`` function uses a slower but
more precise approach to summation.
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it worth adding that for lower-precision floats such as f4, one can pass in dtype='f8' to increase precision?

Copy link
Member Author

Choose a reason for hiding this comment

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

I guess so, although it is growing so long... Maybe the real solution would be to have a longer paragraph about floating point rounding in the user guide and link that...

Copy link
Contributor

@mhvk mhvk left a comment

Choose a reason for hiding this comment

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

Looks good to me!

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.

Numpy mean fails/gives huge precision issues with large arrays and axis selection
6 participants