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

cumtrapz does not behave as expected (Trac #1574) #2099

Closed
scipy-gitbot opened this issue Apr 25, 2013 · 6 comments
Closed

cumtrapz does not behave as expected (Trac #1574) #2099

scipy-gitbot opened this issue Apr 25, 2013 · 6 comments
Labels
Milestone

Comments

@scipy-gitbot
Copy link

Original ticket http://projects.scipy.org/scipy/ticket/1574 on 2011-12-15 by trac user tillahoffmann, assigned to unknown.

The function cumtrapz does not behave as one would expect from the definition of an integral because the length of the output vector is the length of the input vector - 1.

However, if a function is defined on a discrete set of N points then so is the integral.

A 0 should be prepended to the resulting vector.

@scipy-gitbot
Copy link
Author

@rgommers wrote on 2011-12-17

I agree with this. It will break backwards compatibility though, so should be discussed on the mailing list first. Could you bring it up on scipy-dev?

The implementation also looks a bit cryptic. A more understandable one would be welcome. As would a better docstring (Returns, Examples). Furthermore it could reference cumsum/cumprod in numpy.

@scipy-gitbot
Copy link
Author

@WarrenWeckesser wrote on 2011-12-29

An initial 0 sounds reasonable. To maintain backwards compatibility, a keyword argument, say initial, could be added. If initial=None, the function maintains the current behavior and returns N-1 points in the given axis. Otherwise, the value of initial is the first value of the result, and N points are returned in the given axis. The typical case would be initial=0.

Ultimately, however, it would be nice if initial=0 was the default behavior, so I haven't convinced myself that this would be a good interim solution.

@scipy-gitbot
Copy link
Author

@rgommers wrote on 2011-12-29

Using Google Code Search I see that cumtrapz is used quite a bit, and in the code snippets it displays I don't see people prepending a 0 immediately. Therefore my conclusion would be that this is not worth breaking backwards compatibility for. +1 for initial=None.

@scipy-gitbot
Copy link
Author

@rgommers wrote on 2012-01-04

Added initial kw in #125, please review it there.

@scipy-gitbot
Copy link
Author

Milestone changed to 0.11.0 by @rgommers on 2012-01-04

@scipy-gitbot
Copy link
Author

@rgommers wrote on 2012-01-31

Added initial kw in 6eb2da0.

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

No branches or pull requests

1 participant