Re: [Numpy-discussion] Want cumsum-like function

2010-02-25 Thread Peter Shinners
On 02/24/2010 11:48 PM, Friedrich Romstedt wrote: > 2010/2/25 Peter Shinners: > >> I want a function that works like cumsum, but starts at zero, instead of >> starting with the first actual value. >> >> [...] >> >> tallies = np.cumsum(initial_array) >> np.subtract(tallies, tallies[0], tallies)

Re: [Numpy-discussion] Want cumsum-like function

2010-02-24 Thread Friedrich Romstedt
2010/2/25 Peter Shinners : > I want a function that works like cumsum, but starts at zero, instead of > starting with the first actual value. > > [...] > > tallies = np.cumsum(initial_array) > np.subtract(tallies, tallies[0], tallies) Also note that this wouln't work as the example result [0, 3, 6

Re: [Numpy-discussion] Want cumsum-like function

2010-02-24 Thread Robert Kern
On Wed, Feb 24, 2010 at 23:03, Peter Shinners wrote: > On 02/24/2010 09:00 PM, Robert Kern wrote: >> On Wed, Feb 24, 2010 at 22:53, Peter Shinners  wrote: >> >>> I want a function that works like cumsum, but starts at zero, instead of >>> starting with the first actual value. >>> >>> For example;

Re: [Numpy-discussion] Want cumsum-like function

2010-02-24 Thread Peter Shinners
On 02/24/2010 09:00 PM, Robert Kern wrote: > On Wed, Feb 24, 2010 at 22:53, Peter Shinners wrote: > >> I want a function that works like cumsum, but starts at zero, instead of >> starting with the first actual value. >> >> For example; I have an array with [4,3,3,1]. >> Cumsum will give me an

Re: [Numpy-discussion] Want cumsum-like function

2010-02-24 Thread Robert Kern
On Wed, Feb 24, 2010 at 22:53, Peter Shinners wrote: > I want a function that works like cumsum, but starts at zero, instead of > starting with the first actual value. > > For example; I have an array with [4,3,3,1]. > Cumsum will give me an array with [4,7,10,11]. > I want an array that is like [

[Numpy-discussion] Want cumsum-like function

2010-02-24 Thread Peter Shinners
I want a function that works like cumsum, but starts at zero, instead of starting with the first actual value. For example; I have an array with [4,3,3,1]. Cumsum will give me an array with [4,7,10,11]. I want an array that is like [0,4,7,8]. It looks like I could indirectly do this: tallies =