You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
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.
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.
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.
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.
The text was updated successfully, but these errors were encountered: